/// <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() { // 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" }; // Iterate through serialized properties and draw them like the Inspector (But with ports) SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; EditorGUIUtility.labelWidth = 84; while (iterator.NextVisible(enterChildren)) { enterChildren = false; if (excludes.Contains(iterator.name)) { continue; } NodeEditorGUILayout.PropertyField(iterator, true); } // 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(); }
/// <summary> Like OnBodyGUI(), but only draws ports, ignoring other fields </summary> public void OnBodyGUILight() { // 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" }; portPositions = new Dictionary <XNode.NodePort, Vector2>(); SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; EditorGUIUtility.labelWidth = 84; while (iterator.NextVisible(enterChildren)) { enterChildren = false; if (excludes.Contains(iterator.name)) { continue; } XNode.Node node = iterator.serializedObject.targetObject as XNode.Node; XNode.NodePort port = node.GetPort(iterator.name); if (port == null) { continue; } NodeEditorGUILayout.PropertyField(iterator, true); } serializedObject.ApplyModifiedProperties(); }
protected override void DrawPropertyLayout(GUIContent label) { Node node = Property.Tree.WeakTargets[0] as Node; NodePort port = node.GetInputPort(Property.Name); if (!NodeEditor.inNodeEditor) { if (Attribute.backingValue == xNode.Node.ShowBackingValue.Always || Attribute.backingValue == xNode.Node.ShowBackingValue.Unconnected && !port.IsConnected) { CallNextDrawer(label); } return; } if (Property.Tree.WeakTargets.Count > 1) { SirenixEditorGUI.WarningMessageBox("Cannot draw ports with multiple nodes selected"); return; } if (port != null) { var portPropoerty = Property.Tree.GetUnityPropertyForPath(Property.UnityPropertyPath); if (portPropoerty == null) { SirenixEditorGUI.ErrorMessageBox("Port property missing at: " + Property.UnityPropertyPath); return; } else { var labelWidth = Property.GetAttribute <LabelWidthAttribute>(); if (labelWidth != null) { GUIHelper.PushLabelWidth(labelWidth.Width); } NodeEditorGUILayout.PropertyField(portPropoerty, label == null ? GUIContent.none : label, true, GUILayout.MinWidth(30)); if (labelWidth != null) { GUIHelper.PopLabelWidth(); } } } }
/// <summary> Draws standard field editors for all public fields </summary> public virtual void OnBodyGUI() { string[] excludes = { "m_Script", "graph", "position", "ports" }; portPositions = new Dictionary <XNode.NodePort, Vector2>(); SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; EditorGUIUtility.labelWidth = 84; while (iterator.NextVisible(enterChildren)) { enterChildren = false; if (excludes.Contains(iterator.name)) { continue; } NodeEditorGUILayout.PropertyField(iterator, true); } }
/// <summary> Like OnBodyGUI(), but only draws fields whose name is in selected[], ignoring other fields </summary> public void OnBodyGUISelected(string[] selected) { serializedObject.Update(); portPositions = new Dictionary <XNode.NodePort, Vector2>(); SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; EditorGUIUtility.labelWidth = 84; while (iterator.NextVisible(enterChildren)) { if (!selected.Contains(iterator.name)) { continue; } NodeEditorGUILayout.PropertyField(iterator, true); } serializedObject.ApplyModifiedProperties(); }
protected virtual void PropertyField(SerializedProperty property, bool includeChildren = true, params GUILayoutOption[] options) { NodeEditorGUILayout.PropertyField(property, includeChildren, options); }