- Home /
Showing a second ObjectPicker as soon as the first one closes freezes the editor
In an editor I'm trying to show 2 ObjectPicker 's consecutively, I need the editor to select 2 different object one after the other. The second picker will be shown right after the first one is closed. But this freezes the Unity editor as if it has entered an endless loop. Am I doing something wrong or is this a bug? Please take a look at a very simplified test code below.
Edit: If I do these when "ObjectSelectorUpdated" event is raised, it doesn't freeze the editor. "ObjectSelectorClosed" causes the problem.
using UnityEngine;
using UnityEditor;
internal sealed class BugTest : EditorWindow {
private int _id1;
private int _id2;
[MenuItem("BUG/Object Picker Freeze Test")]
private static void Init() {
var window = GetWindow<BugTest>();
window.Show();
}
private void OnGUI() {
if (GUILayout.Button("Open Object Picker")) {
_id1 = GUIUtility.GetControlID(FocusType.Passive);
_id2 = GUIUtility.GetControlID(FocusType.Passive);
EditorGUIUtility.ShowObjectPicker<Transform>(null, true, string.Empty, _id1);
}
var e = Event.current;
if (e.type == EventType.ExecuteCommand &&
e.commandName == "ObjectSelectorClosed" &&
EditorGUIUtility.GetObjectPickerControlID() == _id1) {
e.Use();
Debug.Log("First object picker is closed, now trying to show the second object picker!");
EditorGUIUtility.ShowObjectPicker<Transform>(null, true, string.Empty, _id2);
}
}
}
Your answer
Follow this Question
Related Questions
SearchableEditorWindow 2 Answers
Custom inspector difficulties creating a Box / Group like widget 1 Answer
I give up. My Foldout creates a very small space when expanded. How do I get rid of it? 0 Answers
CustomPropertyDrawer with UnityEvent 1 Answer
GUILayout.BeginHorizontal sluggish in custom inspector 0 Answers