DebuggerComponent.InputAccelerationInformationWindow.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 UnityEngine;
  8. namespace UnityGameFramework.Runtime
  9. {
  10. public partial class DebuggerComponent
  11. {
  12. private sealed class InputAccelerationInformationWindow : ScrollableDebuggerWindowBase
  13. {
  14. protected override void OnDrawScrollableWindow()
  15. {
  16. GUILayout.Label("<b>Input Acceleration Information</b>");
  17. GUILayout.BeginVertical("box");
  18. {
  19. DrawItem("Acceleration:", Input.acceleration.ToString());
  20. DrawItem("Acceleration Event Count:", Input.accelerationEventCount.ToString());
  21. DrawItem("Acceleration Events:", GetAccelerationEventsString(Input.accelerationEvents));
  22. }
  23. GUILayout.EndVertical();
  24. }
  25. private string GetAccelerationEventString(AccelerationEvent accelerationEvent)
  26. {
  27. return string.Format("{0}, {1}", accelerationEvent.acceleration.ToString(), accelerationEvent.deltaTime.ToString());
  28. }
  29. private string GetAccelerationEventsString(AccelerationEvent[] accelerationEvents)
  30. {
  31. string[] accelerationEventStrings = new string[accelerationEvents.Length];
  32. for (int i = 0; i < accelerationEvents.Length; i++)
  33. {
  34. accelerationEventStrings[i] = GetAccelerationEventString(accelerationEvents[i]);
  35. }
  36. return string.Join("; ", accelerationEventStrings);
  37. }
  38. }
  39. }
  40. }