AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SolverHandlerEditor.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
5 using UnityEditor;
6 using UnityEngine;
7 
8 namespace HoloToolkit.Unity.UX
9 {
10  [CustomEditor(typeof(SolverHandler))]
12  {
13  private SerializedProperty trackedObjectReferenceProperty;
14  private SerializedProperty transformTargetProperty;
15  private SerializedProperty additionalOffsetProperty;
16  private SerializedProperty additionalRotationProperty;
17  private SerializedProperty updateSolversProperty;
18  private SolverHandler solverHandler;
19  private GUIContent trackedTransformGUIContent = new GUIContent("Tracked Transform");
20 
21  protected override void OnEnable()
22  {
23  base.OnEnable();
24 
25  trackedObjectReferenceProperty = serializedObject.FindProperty("trackedObjectToReference");
26  transformTargetProperty = serializedObject.FindProperty("transformTarget");
27  additionalOffsetProperty = serializedObject.FindProperty("additionalOffset");
28  additionalRotationProperty = serializedObject.FindProperty("additionalRotation");
29  updateSolversProperty = serializedObject.FindProperty("updateSolvers");
30 
31  solverHandler = target as SolverHandler;
32  }
33 
34  public override void OnInspectorGUI()
35  {
36  serializedObject.Update();
37  EditorGUILayout.Space();
38 
39  EditorGUI.BeginChangeCheck();
40  EditorGUILayout.PropertyField(trackedObjectReferenceProperty);
41  bool trackedObjectChanged = EditorGUI.EndChangeCheck();
42 
43  EditorGUI.BeginChangeCheck();
44  EditorGUILayout.PropertyField(additionalOffsetProperty);
45  EditorGUILayout.PropertyField(additionalRotationProperty);
46  bool additionalOffsetChanged = EditorGUI.EndChangeCheck();
47 
48  EditorGUILayout.PropertyField(transformTargetProperty, trackedTransformGUIContent);
49  EditorGUILayout.PropertyField(updateSolversProperty);
50 
51  serializedObject.ApplyModifiedProperties();
52 
53  if (trackedObjectChanged)
54  {
55  solverHandler.TransformTarget = null;
56  solverHandler.AttachToNewTrackedObject();
57  }
58 
59  if (additionalOffsetChanged)
60  {
61  solverHandler.AdditionalOffset = additionalOffsetProperty.vector3Value;
62  solverHandler.AdditionalRotation = additionalRotationProperty.vector3Value;
63  }
64  }
65  }
66 }
virtual void AttachToNewTrackedObject()