From 098f14f921d8027dc1bd6289812ca723ce222ce9 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Thu, 9 May 2019 00:23:53 +0200 Subject: [PATCH] WIP --- Scripts/Editor/NodeEditorGUILayout.cs | 16 ++++----- Scripts/Interfaces/INode.cs | 5 ++- Scripts/Node.cs | 49 ++------------------------- 3 files changed, 12 insertions(+), 58 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index a84a061..2776b0f 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -315,7 +315,7 @@ namespace XNodeEditor { list.DoLayoutList(); } - private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.INode.ConnectionType connectionType, XNode.INode.TypeConstraint typeConstraint, Action onCreation) { + private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, Action onCreation) { bool hasArrayData = arrayData != null && arrayData.isArray; XNode.INode node = serializedObject.targetObject as XNode.INode; ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); @@ -404,10 +404,10 @@ namespace XNodeEditor { int i = 0; while (node.HasPort(newName)) newName = fieldName + " " + (++i); - if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, XNode.INode.TypeConstraint.None, newName); - else node.AddDynamicInput(type, connectionType, typeConstraint, newName); + if (io == XNode.NodePort.IO.Output) node.AddDynamicPort(type, XNode.NodePort.IO.Output, connectionType, XNode.Node.TypeConstraint.None, newName); + else node.AddDynamicPort(type, XNode.NodePort.IO.Input, connectionType, typeConstraint, newName); serializedObject.Update(); - EditorUtility.SetDirty(node); + EditorUtility.SetDirty((UnityEngine.Object) node); if (hasArrayData) { arrayData.InsertArrayElementAtIndex(arrayData.arraySize); } @@ -444,7 +444,7 @@ namespace XNodeEditor { // Remove the last dynamic port, to avoid messing up the indexing node.RemoveDynamicPort(dynamicPorts[dynamicPorts.Count() - 1].fieldName); serializedObject.Update(); - EditorUtility.SetDirty(node); + EditorUtility.SetDirty((UnityEngine.Object) node); } else { Debug.LogWarning("DynamicPorts[" + index + "] out of range. Length was " + dynamicPorts.Count + ". Skipping."); } @@ -470,9 +470,9 @@ namespace XNodeEditor { string newName = arrayData.name + " 0"; int i = 0; while (node.HasPort(newName)) newName = arrayData.name + " " + (++i); - if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint, newName); - else node.AddDynamicInput(type, connectionType, typeConstraint, newName); - EditorUtility.SetDirty(node); + if (io == XNode.NodePort.IO.Output) node.AddDynamicPort(type, XNode.NodePort.IO.Output, connectionType, typeConstraint, newName); + else node.AddDynamicPort(type, XNode.NodePort.IO.Input, connectionType, typeConstraint, newName); + EditorUtility.SetDirty((UnityEngine.Object) node); dynamicPortCount++; } while (arrayData.arraySize < dynamicPortCount) { diff --git a/Scripts/Interfaces/INode.cs b/Scripts/Interfaces/INode.cs index bc96440..d491bce 100644 --- a/Scripts/Interfaces/INode.cs +++ b/Scripts/Interfaces/INode.cs @@ -14,14 +14,13 @@ namespace XNode { IEnumerable Ports { get; } IEnumerable Outputs { get; } IEnumerable Inputs { get; } - IEnumerable InstancePorts { get; } + IEnumerable DynamicPorts { get; } NodePort AddDynamicPort(Type type, NodePort.IO direction, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = Node.TypeConstraint.None, string fieldName = null); - NodePort RemoveDynamicPort(string fieldName); + void RemoveDynamicPort(string fieldName); NodePort GetInputPort(string fieldName); NodePort GetOutputPort(string fieldName); void OnCreateConnection(NodePort from, NodePort to); void OnRemoveConnection(NodePort port); void ClearConnections(); - void RemoveInstancePort(string fieldName); } } \ No newline at end of file diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 2fe4968..163679d 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -51,47 +51,6 @@ namespace XNode { Strict, } -#region Obsolete - [Obsolete("Use DynamicPorts instead")] - public IEnumerable InstancePorts { get { return DynamicPorts; } } - - [Obsolete("Use DynamicOutputs instead")] - public IEnumerable InstanceOutputs { get { return DynamicOutputs; } } - - [Obsolete("Use DynamicInputs instead")] - public IEnumerable InstanceInputs { get { return DynamicInputs; } } - - [Obsolete("Use AddDynamicInput instead")] - public NodePort AddInstanceInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddInstanceInput(type, connectionType, typeConstraint, fieldName); - } - - [Obsolete("Use AddDynamicOutput instead")] - public NodePort AddInstanceOutput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicOutput(type, connectionType, typeConstraint, fieldName); - } - - [Obsolete("Use AddDynamicPort instead")] - private NodePort AddInstancePort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, direction, connectionType, typeConstraint, fieldName); - } - - [Obsolete("Use RemoveDynamicPort instead")] - public void RemoveInstancePort(string fieldName) { - RemoveDynamicPort(fieldName); - } - - [Obsolete("Use RemoveDynamicPort instead")] - public void RemoveInstancePort(NodePort port) { - RemoveDynamicPort(port); - } - - [Obsolete("Use ClearDynamicPorts instead")] - public void ClearInstancePorts() { - ClearDynamicPorts(); - } -#endregion - #region Interface implementation string INode.Name { get { return name; } set { name = value; } } INodeGraph INode.Graph { get { return graph; } } @@ -140,14 +99,14 @@ namespace XNode { /// /// public NodePort AddDynamicInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return ((INode)this).AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint, fieldName); + return ((INode) this).AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint, fieldName); } /// Convenience function. /// /// public NodePort AddDynamicOutput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return ((INode)this).AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint, fieldName); + return ((INode) this).AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint, fieldName); } /// Add a dynamic, serialized port to this node. @@ -265,8 +224,6 @@ namespace XNode { public class InputAttribute : Attribute { public ShowBackingValue backingValue; public ConnectionType connectionType; - [Obsolete("Use dynamicPortList instead")] - public bool instancePortList { get { return dynamicPortList; } set { dynamicPortList = value; } } public bool dynamicPortList; public TypeConstraint typeConstraint; @@ -288,8 +245,6 @@ namespace XNode { public class OutputAttribute : Attribute { public ShowBackingValue backingValue; public ConnectionType connectionType; - [Obsolete("Use dynamicPortList instead")] - public bool instancePortList { get { return dynamicPortList; } set { dynamicPortList = value; } } public bool dynamicPortList; /// Mark a serializable field as an output port. You can access this through