FrozenTimeDebugGUI.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using UnityEngine;
  3. namespace Tools
  4. {
  5. public class FrozenTimeDebugGUI : DebugGuiBase
  6. {
  7. protected override string UIDebugButtonName
  8. {
  9. get
  10. {
  11. return "帧冻结测试";
  12. }
  13. }
  14. protected override void GUIStart()
  15. {
  16. float num = (float)Screen.width;
  17. this.GUIArea = new Rect(num / 2f - 320f, 20f, 640f, 500f);
  18. }
  19. public override void OnDebugGUI()
  20. {
  21. GUILayout.BeginArea(this.GUIArea);
  22. GUILayout.BeginVertical("box", new GUILayoutOption[0]);
  23. GUILayout.BeginHorizontal(new GUILayoutOption[]
  24. {
  25. GUILayout.Width(600f)
  26. });
  27. GUILayout.Label(string.Format("frozen frames: {0}", this.frozenClip), new GUILayoutOption[0]);
  28. GUILayout.FlexibleSpace();
  29. this.frozenClip = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)this.frozenClip, 0f, 60f, new GUILayoutOption[]
  30. {
  31. GUILayout.Width(400f)
  32. }));
  33. GUILayout.EndHorizontal();
  34. GUILayout.BeginHorizontal(new GUILayoutOption[]
  35. {
  36. GUILayout.Width(600f)
  37. });
  38. GUILayout.FlexibleSpace();
  39. if (GUILayout.Button("Test", new GUILayoutOption[]
  40. {
  41. GUILayout.Width(200f)
  42. }))
  43. {
  44. SingletonMono<WorldTime>.Instance.TimeFrozenByFixedFrame(this.frozenClip, WorldTime.FrozenArgs.FrozenType.All, true);
  45. }
  46. GUILayout.FlexibleSpace();
  47. GUILayout.EndHorizontal();
  48. GUILayout.EndVertical();
  49. GUILayout.EndArea();
  50. }
  51. private Rect GUIArea;
  52. private int frozenClip = 10;
  53. }
  54. }