/// <summary> Draws standard field editors for all public fields </summary> public virtual void OnBodyGUI() { #if ODIN_INSPECTOR inNodeEditor = true; #endif // Unity specifically requires this to save/update any serial object. // serializedObject.Update(); must go at the start of an inspector gui, and // serializedObject.ApplyModifiedProperties(); goes at the end. serializedObject.Update(); string[] excludes = { "m_Script", "graph", "position", "ports" }; #if ODIN_INSPECTOR InspectorUtilities.BeginDrawPropertyTree(objectTree, true); GUIHelper.PushLabelWidth(84); objectTree.Draw(true); InspectorUtilities.EndDrawPropertyTree(objectTree); GUIHelper.PopLabelWidth(); #else // Iterate through serialized properties and draw them like the Inspector (But with ports) SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; while (iterator.NextVisible(enterChildren)) { enterChildren = false; if (excludes.Contains(iterator.name)) { continue; } NodeEditorGUILayout.PropertyField(iterator, true); } #endif // Iterate through dynamic ports and draw them in the order in which they are serialized foreach (XNode.NodePort dynamicPort in target.DynamicPorts) { if (NodeEditorGUILayout.IsDynamicPortListPort(dynamicPort)) { continue; } NodeEditorGUILayout.PortField(dynamicPort); } serializedObject.ApplyModifiedProperties(); #if ODIN_INSPECTOR // Call repaint so that the graph window elements respond properly to layout changes coming from Odin if (GUIHelper.RepaintRequested) { GUIHelper.ClearRepaintRequest(); window.Repaint(); } #else window.Repaint(); #endif #if ODIN_INSPECTOR inNodeEditor = false; #endif }
/// <summary> Draws standard field editors for all public fields </summary> public virtual void OnBodyGUI() { #if ODIN_INSPECTOR inNodeEditor = true; #endif // Unity specifically requires this to save/update any serial object. // serializedObject.Update(); must go at the start of an inspector gui, and // serializedObject.ApplyModifiedProperties(); goes at the end. serializedObject.Update(); string[] excludes = { "m_Script", "graph", "position", "ports" }; #if ODIN_INSPECTOR InspectorUtilities.BeginDrawPropertyTree(objectTree, true); GUIHelper.PushLabelWidth(84); objectTree.Draw(true); InspectorUtilities.EndDrawPropertyTree(objectTree); GUIHelper.PopLabelWidth(); #else if (typeof(UnityEngine.Object).IsAssignableFrom(target.Type)) { if (target.GetType() == typeof(BlackboardNonSerializedVariable)) { target.Value = EditorGUILayout.ObjectField((UnityEngine.Object)target.Value, target.Type, true); } else { target.Value = EditorGUILayout.ObjectField((UnityEngine.Object)target.Value, target.Type, false); } } else { switch (target.Type.Name) { case ("Int32"): target.Value = EditorGUILayout.IntField((int)target.Value); break; case ("Single"): target.Value = EditorGUILayout.FloatField((float)target.Value); break; case ("Vector2"): target.Value = EditorGUILayout.Vector2Field("", (Vector2)target.Value); break; case ("Vector3"): target.Value = EditorGUILayout.Vector3Field("", (Vector3)target.Value); break; case ("Vector4"): target.Value = EditorGUILayout.Vector4Field("", (Vector4)target.Value); break; case ("String"): target.Value = EditorGUILayout.TextField("", (string)target.Value); break; case ("Boolean"): target.Value = EditorGUILayout.Toggle("", (bool)target.Value); break; default: EditorGUILayout.LabelField(target.Type.Name); break; } } // Iterate through serialized properties and draw them like the Inspector (But with ports) //SerializedProperty iterator = serializedObject.GetIterator(); //bool enterChildren = true; //while (iterator.NextVisible(enterChildren)) { // enterChildren = false; // if (excludes.Contains(iterator.name)) continue; // EditorGUILayout.PropertyField(iterator, true); //} #endif serializedObject.ApplyModifiedProperties(); #if ODIN_INSPECTOR // Call repaint so that the graph window elements respond properly to layout changes coming from Odin if (GUIHelper.RepaintRequested) { GUIHelper.ClearRepaintRequest(); window.Repaint(); } #endif #if ODIN_INSPECTOR inNodeEditor = false; #endif }