- Home /
How to use UnityEditor.Highlight properly?
I' ve tried to use the new Highlighter functionality. I'm implementing a custom inspector, and I want to highlight some parts of the inspector window. I'm doing:
EditorGUILayout.LabelField (prefix, label);
Rect labelRect = GUILayoutUtility.GetLastRect ();
if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2 && labelRect.Contains (Event.current.mousePosition)) {
Highlighter.Highlight ("Inspector", "Transform");
Event.current.Use (); // tried without it, too.. but I get the "Getting control 0's position.. " error
}
But I get several errors:
ArgumentException: Getting control 0's position in a group with only 0 controls when doing mouseDown
Aborting
UnityEngine.GUILayoutGroup.GetNext ()
UnityEngine.GUILayoutUtility.DoGetRect (Single minWidth, Single maxWidth, Single minHeight, Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options)
UnityEngine.GUILayoutUtility.GetRect (Single minWidth, Single maxWidth, Single minHeight, Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options)
UnityEditor.EditorGUILayout.GetControlRect (Boolean hasLabel, Single height, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options)
UnityEditor.EditorGUILayout.GetControlRect (Boolean hasLabel, Single height, UnityEngine.GUILayoutOption[] options)
UnityEditor.EditorGUILayout.LabelField (UnityEngine.GUIContent label, UnityEngine.GUIContent label2, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options)
InvalidOperationException: Operation is not valid due to the current state of the object
System.Collections.Stack.Peek () (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections/Stack.cs:321)
UnityEngine.GUILayoutUtility.EndLayoutGroup ()
UnityEngine.GUILayout.EndVertical ()
UnityEditor.EditorGUILayout.EndVertical ()
UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty)
UnityEditor.InspectorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
How should I use this class? I'm missing some basic layout limitations/wrong usage here?
Comment
Your answer
