- Home /
ObjectField in GUILayout.Window Not Working - Returns None
Hi, I'm having a bit of difficulty pinpointing the a problem. 1. I have an EditorWindow. 2. Within that editor window I have GUIWindows. 3. Within the GUIWindows I have objectFields. 4. In the DoWindow function I have EditorGUIUtility.LookLikeControls(); and that makes the little selection button and object field show up.
The Problem: When I click to select an object, the selection window opens fine, but when I do select an object, it still shows "None" in the ObjectField. This happens only while inside the GUIWindow().
Snippet below.
var animClip : AnimationClip;
function EntryWindow (windowID : int) {
EditorGUIUtility.LookLikeControls();
animClip = EditorGUILayout.ObjectField("Animation Clip:", animClip, AnimationClip, true);
}
Any ideas what my problem can be?
Answer by stantler · Nov 19, 2012 at 10:56 AM
It's a bug. You can draw this element above your window. It'a awful, but working.
C#
Rect rect = new Rect();
AnimationClip clip;
void OnGUI()
{
rect = GUILayout.Window(i, rect , EntryWindow, "Hi There");
clip= (Object)EditorGUI.ObjectField(rect,"Script", clip, typeof(AnimationClip), true);
}
Your answer
Follow this Question
Related Questions
custom editor EditorGUILayout.ObjectField only shows the assets folder 1 Answer
[CanEditMultipleObjects] doesn't actually work for an ObjectField? 2 Answers
EditorGUILayout.ObjectField for Array 1 Answer
How to know the event that mouse click on a EditorGUILayout.ObjectField(...)? 1 Answer
create "draggable reference" within custom inspector? 1 Answer