Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Fixed configuratoin profile picker (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson authored Apr 19, 2021
1 parent ef4d278 commit 0ae3ba5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Editor/MixedRealityToolkitInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ namespace XRTK.Editor
[CustomEditor(typeof(MixedRealityToolkit))]
public class MixedRealityToolkitInspector : UnityEditor.Editor
{
private const string ObjectSelectorClosed = "ObjectSelectorClosed";
private const string ObjectSelectorUpdated = "ObjectSelectorUpdated";

private SerializedProperty activeProfile;

private int currentPickerWindow = -1;
private bool checkChange;

private UnityEditor.Editor profileInspector;

private void Awake()
Expand Down Expand Up @@ -77,7 +82,9 @@ public override void OnInspectorGUI()
case 0:
EditorGUIUtility.PingObject(target);
EditorApplication.delayCall += () =>
{
EditorUtility.DisplayDialog("Attention!", "No root profile for the Mixed Reality Toolkit was found.\n\nYou'll need to create a new one.", "OK");
};
break;
case 1:
var rootProfilePath = AssetDatabase.GetAssetPath(rootProfiles[0]);
Expand All @@ -94,12 +101,8 @@ public override void OnInspectorGUI()
};
break;
default:
EditorApplication.delayCall += () =>
{
EditorUtility.DisplayDialog("Attention!", "You must choose a profile for the Mixed Reality Toolkit.", "OK");
currentPickerWindow = GUIUtility.GetControlID(FocusType.Passive);
EditorGUIUtility.ShowObjectPicker<MixedRealityToolkitRootProfile>(null, false, string.Empty, currentPickerWindow);
};
currentPickerWindow = GUIUtility.GetControlID(FocusType.Passive);
EditorGUIUtility.ShowObjectPicker<MixedRealityToolkitRootProfile>(null, false, string.Empty, currentPickerWindow);
break;
}

Expand All @@ -110,11 +113,11 @@ public override void OnInspectorGUI()
{
switch (commandName)
{
case "ObjectSelectorUpdated":
case ObjectSelectorUpdated:
activeProfile.objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
changed = true;
break;
case "ObjectSelectorClosed":
case ObjectSelectorClosed:
activeProfile.objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
currentPickerWindow = -1;
changed = true;
Expand All @@ -127,7 +130,7 @@ public override void OnInspectorGUI()
}
}

if (activeProfile.objectReferenceValue != null)
if (!activeProfile.objectReferenceValue.IsNull())
{
var rootProfile = activeProfile.objectReferenceValue as MixedRealityToolkitRootProfile;

Expand All @@ -141,7 +144,7 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.Space();
Rect rect = new Rect(GUILayoutUtility.GetLastRect()) { height = 0.75f };
var rect = new Rect(GUILayoutUtility.GetLastRect()) { height = 0.75f };
EditorGUI.DrawRect(rect, Color.gray);
EditorGUILayout.Space();

Expand Down Expand Up @@ -215,7 +218,7 @@ void SetStartScene()
}
catch (Exception e)
{
Debug.LogError(e.ToString());
Debug.LogError(e);
}
}
}
Expand Down

0 comments on commit 0ae3ba5

Please sign in to comment.