Can't update ObjectField after object is selected
Hi! I wanna create an editor window to control my waypoint system, and I need an ObjectField to be able to set an optional parent for all waypoints in the scene. So, here's the code of the class
using UnityEngine;
using System.Collections;
using UnityEditor;
public class WaypointBuilderWindow : EditorWindow {
[MenuItem ("Custom Extensions/Waypoints Builder")]
public static void ShowWindow () {
EditorWindow.GetWindow(typeof(WaypointBuilderWindow));
}
void OnGUI () {
GUI.skin.label.wordWrap = true;
GUILayout.Label ("Here you can set the parent for all waypoints (optionally). If parent is not set, the root object will be used instead");
GameObject gameObject = (GameObject)EditorGUILayout.ObjectField("Waypoint Container", null, typeof(GameObject), true);
if (gameObject) {
Debug.Log("Object Selected!");
}
}
void OnInspectorUpdate() {
Repaint();
}
}
I also created an empty game object in my scene to set it as parent. But when I drag it to the object field, it just doesn't update it with the name of the selected object (like it usually happens for public vars in the inspector). The debug outputs "Object Selected!" normally and I can get a reference to this object, but the field remains unchanged visually
What am I missing here?
Answer by ArcherLew · Dec 18, 2018 at 02:30 AM
i have similar problem with you about the TextField, which cannot update with focus on it .
Your answer
Follow this Question
Related Questions
Webview in custom Unity Editor Window? 0 Answers
My EditorWindow won't display properly, even when commented out. 0 Answers
Object field in the scene view - Custom Editor Script 0 Answers
Editor Window 1 Answer