CalibratableTrackerEditor.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Globalization;
  3. using Tracking;
  4. using UnityEditor;
  5. using UnityEngine;
  6. // ReSharper disable once CheckNamespace
  7. public abstract class CalibratableTrackerEditor : UnityEditor.Editor
  8. {
  9. protected CalibratableTracker tracker;
  10. protected virtual void OnEnable()
  11. {
  12. tracker = (CalibratableTracker) target;
  13. }
  14. public override void OnInspectorGUI()
  15. {
  16. DrawDefaultInspector();
  17. if (!(EditorApplication.isPlaying || EditorApplication.isPaused)) return;
  18. tracker.bicycleTransform = (Transform) EditorGUILayout.ObjectField("Bicycle Transform", tracker.bicycleTransform,
  19. typeof(Transform), false);
  20. EditorGUILayout.Space();
  21. EditorGUILayout.LabelField("Attach Vive Tracker to Wheel and press Button to calibrate");
  22. if (GUILayout.Button("Calibrate")) tracker.Calibrate();
  23. EditorGUILayout.Space();
  24. EditorGUILayout.LabelField("Data", EditorStyles.boldLabel);
  25. EditorGUILayout.LabelField("Zero Rot:", tracker.ZeroRot.ToString());
  26. EditorGUILayout.LabelField("Zero Pos:", tracker.ZeroPos.ToString());
  27. EditorGUILayout.Space();
  28. EditorGUILayout.LabelField("Relative Position", tracker.RelativePosition.ToString());
  29. EditorGUILayout.LabelField("Relative Rotation", tracker.RelativeRotation.ToString());
  30. }
  31. }