ScrollableDebuggerWindowBase.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //------------------------------------------------------------
  2. // Game Framework v3.x
  3. // Copyright © 2013-2017 Jiang Yin. All rights reserved.
  4. // Homepage: http://gameframework.cn/
  5. // Feedback: mailto:jiangyin@gameframework.cn
  6. //------------------------------------------------------------
  7. using GameFramework.Debugger;
  8. using System;
  9. using UnityEngine;
  10. namespace UnityGameFramework.Runtime
  11. {
  12. public abstract class ScrollableDebuggerWindowBase : IDebuggerWindow
  13. {
  14. private const float TitleWidth = 240f;
  15. private Vector2 m_ScrollPosition = Vector2.zero;
  16. public virtual void Initialize(params object[] args)
  17. {
  18. }
  19. public virtual void Shutdown()
  20. {
  21. }
  22. public virtual void OnEnter()
  23. {
  24. }
  25. public virtual void OnLeave()
  26. {
  27. }
  28. public virtual void OnUpdate(float elapseSeconds, float realElapseSeconds)
  29. {
  30. }
  31. public void OnDraw()
  32. {
  33. m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
  34. {
  35. OnDrawScrollableWindow();
  36. }
  37. GUILayout.EndScrollView();
  38. }
  39. protected abstract void OnDrawScrollableWindow();
  40. protected void DrawItem(string title, string content)
  41. {
  42. GUILayout.BeginHorizontal();
  43. {
  44. GUILayout.Label(title, GUILayout.Width(TitleWidth));
  45. GUILayout.Label(content);
  46. }
  47. GUILayout.EndHorizontal();
  48. }
  49. }
  50. }