Skip to content

Commit 15629a8

Browse files
authored
Merge pull request #9679 from keveleigh/editor-recreate
Don't constantly recreate the base profile editor
2 parents 4ff4b52 + 5925217 commit 15629a8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Assets/MRTK/Core/Inspectors/MixedRealityToolkitInspector.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.MixedReality.Toolkit.Editor
1111
public class MixedRealityToolkitInspector : UnityEditor.Editor
1212
{
1313
private SerializedProperty activeProfile;
14+
private UnityEditor.Editor activeProfileEditor;
1415

1516
private void OnEnable()
1617
{
@@ -33,7 +34,7 @@ public override void OnInspectorGUI()
3334
{
3435
if (GUILayout.Button("Select Active Instance"))
3536
{
36-
UnityEditor.Selection.activeGameObject = MixedRealityToolkit.Instance.gameObject;
37+
Selection.activeGameObject = MixedRealityToolkit.Instance.gameObject;
3738
}
3839

3940
if (GUILayout.Button("Make this the Active Instance"))
@@ -46,7 +47,7 @@ public override void OnInspectorGUI()
4647

4748
serializedObject.Update();
4849

49-
// If not profile is assigned, then warn user
50+
// If no profile is assigned, then warn user
5051
if (activeProfile.objectReferenceValue == null)
5152
{
5253
EditorGUILayout.HelpBox("MixedRealityToolkit cannot initialize unless an Active Profile is assigned!", MessageType.Error);
@@ -59,12 +60,17 @@ public override void OnInspectorGUI()
5960
if (changed)
6061
{
6162
MixedRealityToolkit.Instance.ResetConfiguration((MixedRealityToolkitConfigurationProfile)activeProfile.objectReferenceValue);
63+
activeProfileEditor = null;
6264
}
6365

64-
if (activeProfile.objectReferenceValue != null)
66+
if (activeProfile.objectReferenceValue != null && activeProfileEditor == null)
67+
{
68+
// For the configuration profile, show the default inspector GUI
69+
activeProfileEditor = CreateEditor(activeProfile.objectReferenceValue);
70+
}
71+
72+
if (activeProfileEditor != null)
6573
{
66-
// For configure, show the default inspector GUI
67-
UnityEditor.Editor activeProfileEditor = CreateEditor(activeProfile.objectReferenceValue);
6874
activeProfileEditor.OnInspectorGUI();
6975
}
7076
}

0 commit comments

Comments
 (0)