- Home /
Function Reference in custom EditorWindow (no Inspector)
I'm making a node editor with a custom Unity EditorWindow. I'd like one of the nodes to be able to select a GameObject and a function on its script, similar to how button event handlers work:
I've found examples of how to do this (with EditorGUILayout.PropertyField(serProp)) when making a Custom Component in the inspector, but it doesn't seem to work when using a separate window (EditorWindow) that is not linked to any kind of game object on its own.
I've tried making a dummy property class (with a string Text) trying to get the control to work but sadly it doesn't:
Node.cs:
Property property = null;
public void OnGUI()
{
InConnector.Draw();
OutConnector.Draw();
GUI.Box(Rect, Title, Style);
Property property = null;
SerializedObject serializedObject = new SerializedObject(property);
SerializedProperty textProperty = serializedObject.FindProperty("Text");
EditorGUILayout.PropertyField(textProperty);
serializedObject.ApplyModifiedProperties();
GUI.Label(new Rect(Left, Top, 150, 50), "Function selector:");
}
Is there a way of selecting an object and a property/function of that object within a custom window. The idea is to have a kind of flow chart to launch functions of various objects consecutively and by using nodes allowing to easily change the order of things.
(I'm guessing the long way of enumerating all GameObjects in the scene and going over all their functions, filling a dropdown menu would work too, but if something existed like how a Button control handles OnClick callback selection, that would be great.
Your answer
Follow this Question
Related Questions
How to get PropertyDrawers in a custom EditorWindow 0 Answers
Editing a List Propertyfield in Editor Extension overwrites previously saved entries. How to fix? 1 Answer
EditorWindow not working when defined in .net/mono Assembly. 2 Answers
EditorWindow loses Texture2D reference on scene change: how to handle? 4 Answers