1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00
This commit is contained in:
Thor Brigsted 2019-05-09 00:23:53 +02:00
parent e89671480c
commit 098f14f921
3 changed files with 12 additions and 58 deletions

View File

@ -315,7 +315,7 @@ namespace XNodeEditor {
list.DoLayoutList(); list.DoLayoutList();
} }
private static ReorderableList CreateReorderableList(string fieldName, List<XNode.NodePort> dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.INode.ConnectionType connectionType, XNode.INode.TypeConstraint typeConstraint, Action<ReorderableList> onCreation) { private static ReorderableList CreateReorderableList(string fieldName, List<XNode.NodePort> dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, Action<ReorderableList> onCreation) {
bool hasArrayData = arrayData != null && arrayData.isArray; bool hasArrayData = arrayData != null && arrayData.isArray;
XNode.INode node = serializedObject.targetObject as XNode.INode; XNode.INode node = serializedObject.targetObject as XNode.INode;
ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true);
@ -404,10 +404,10 @@ namespace XNodeEditor {
int i = 0; int i = 0;
while (node.HasPort(newName)) newName = fieldName + " " + (++i); while (node.HasPort(newName)) newName = fieldName + " " + (++i);
if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, XNode.INode.TypeConstraint.None, newName); if (io == XNode.NodePort.IO.Output) node.AddDynamicPort(type, XNode.NodePort.IO.Output, connectionType, XNode.Node.TypeConstraint.None, newName);
else node.AddDynamicInput(type, connectionType, typeConstraint, newName); else node.AddDynamicPort(type, XNode.NodePort.IO.Input, connectionType, typeConstraint, newName);
serializedObject.Update(); serializedObject.Update();
EditorUtility.SetDirty(node); EditorUtility.SetDirty((UnityEngine.Object) node);
if (hasArrayData) { if (hasArrayData) {
arrayData.InsertArrayElementAtIndex(arrayData.arraySize); arrayData.InsertArrayElementAtIndex(arrayData.arraySize);
} }
@ -444,7 +444,7 @@ namespace XNodeEditor {
// Remove the last dynamic port, to avoid messing up the indexing // Remove the last dynamic port, to avoid messing up the indexing
node.RemoveDynamicPort(dynamicPorts[dynamicPorts.Count() - 1].fieldName); node.RemoveDynamicPort(dynamicPorts[dynamicPorts.Count() - 1].fieldName);
serializedObject.Update(); serializedObject.Update();
EditorUtility.SetDirty(node); EditorUtility.SetDirty((UnityEngine.Object) node);
} else { } else {
Debug.LogWarning("DynamicPorts[" + index + "] out of range. Length was " + dynamicPorts.Count + ". Skipping."); Debug.LogWarning("DynamicPorts[" + index + "] out of range. Length was " + dynamicPorts.Count + ". Skipping.");
} }
@ -470,9 +470,9 @@ namespace XNodeEditor {
string newName = arrayData.name + " 0"; string newName = arrayData.name + " 0";
int i = 0; int i = 0;
while (node.HasPort(newName)) newName = arrayData.name + " " + (++i); while (node.HasPort(newName)) newName = arrayData.name + " " + (++i);
if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint, newName); if (io == XNode.NodePort.IO.Output) node.AddDynamicPort(type, XNode.NodePort.IO.Output, connectionType, typeConstraint, newName);
else node.AddDynamicInput(type, connectionType, typeConstraint, newName); else node.AddDynamicPort(type, XNode.NodePort.IO.Input, connectionType, typeConstraint, newName);
EditorUtility.SetDirty(node); EditorUtility.SetDirty((UnityEngine.Object) node);
dynamicPortCount++; dynamicPortCount++;
} }
while (arrayData.arraySize < dynamicPortCount) { while (arrayData.arraySize < dynamicPortCount) {

View File

@ -14,14 +14,13 @@ namespace XNode {
IEnumerable<NodePort> Ports { get; } IEnumerable<NodePort> Ports { get; }
IEnumerable<NodePort> Outputs { get; } IEnumerable<NodePort> Outputs { get; }
IEnumerable<NodePort> Inputs { get; } IEnumerable<NodePort> Inputs { get; }
IEnumerable<NodePort> InstancePorts { get; } IEnumerable<NodePort> 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 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 GetInputPort(string fieldName);
NodePort GetOutputPort(string fieldName); NodePort GetOutputPort(string fieldName);
void OnCreateConnection(NodePort from, NodePort to); void OnCreateConnection(NodePort from, NodePort to);
void OnRemoveConnection(NodePort port); void OnRemoveConnection(NodePort port);
void ClearConnections(); void ClearConnections();
void RemoveInstancePort(string fieldName);
} }
} }

View File

@ -51,47 +51,6 @@ namespace XNode {
Strict, Strict,
} }
#region Obsolete
[Obsolete("Use DynamicPorts instead")]
public IEnumerable<NodePort> InstancePorts { get { return DynamicPorts; } }
[Obsolete("Use DynamicOutputs instead")]
public IEnumerable<NodePort> InstanceOutputs { get { return DynamicOutputs; } }
[Obsolete("Use DynamicInputs instead")]
public IEnumerable<NodePort> 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 #region Interface implementation
string INode.Name { get { return name; } set { name = value; } } string INode.Name { get { return name; } set { name = value; } }
INodeGraph INode.Graph { get { return graph; } } INodeGraph INode.Graph { get { return graph; } }
@ -265,8 +224,6 @@ namespace XNode {
public class InputAttribute : Attribute { public class InputAttribute : Attribute {
public ShowBackingValue backingValue; public ShowBackingValue backingValue;
public ConnectionType connectionType; public ConnectionType connectionType;
[Obsolete("Use dynamicPortList instead")]
public bool instancePortList { get { return dynamicPortList; } set { dynamicPortList = value; } }
public bool dynamicPortList; public bool dynamicPortList;
public TypeConstraint typeConstraint; public TypeConstraint typeConstraint;
@ -288,8 +245,6 @@ namespace XNode {
public class OutputAttribute : Attribute { public class OutputAttribute : Attribute {
public ShowBackingValue backingValue; public ShowBackingValue backingValue;
public ConnectionType connectionType; public ConnectionType connectionType;
[Obsolete("Use dynamicPortList instead")]
public bool instancePortList { get { return dynamicPortList; } set { dynamicPortList = value; } }
public bool dynamicPortList; public bool dynamicPortList;
/// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutputPort(string)"/> </summary> /// <summary> Mark a serializable field as an output port. You can access this through <see cref="GetOutputPort(string)"/> </summary>