From eb7c9098e9fc045b9fee507e794f255e5baf051c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 21:04:50 +0800 Subject: [PATCH] =?UTF-8?q?!R(Dynamic=20Port=20List)=20=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E6=94=B9=E5=8F=98,=E8=BF=99=E6=AC=A1=E9=87=8D=E5=86=99?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E5=86=8D=E4=B9=9F=E4=B8=8D=E4=BC=9A=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E6=9C=AA=E7=9F=A5=E7=9A=84=E9=94=99=E8=AF=AF=3D-=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUILayout.cs | 46 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 857672a..bd9e71d 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -397,28 +397,42 @@ namespace XNodeEditor { list.onReorderCallbackWithDetails = (reorderableList, index, newIndex) => { - var port = serializedObject.FindProperty(Node.PortFieldName); - SerializedProperty keys = port.FindPropertyRelative(Node.KeysFieldName); - SerializedProperty values = port.FindPropertyRelative(Node.ValuesFieldName); - var count = 0; - - foreach (var nodePort in node.Ports) + var portSer = serializedObject.FindProperty(Node.PortFieldName); + SerializedProperty keys = portSer.FindPropertyRelative(Node.KeysFieldName); + SerializedProperty values = portSer.FindPropertyRelative(Node.ValuesFieldName); + + var baseIndex = 0; + + if (io == NodePort.IO.Output) { - if (!reorderableList.list.Contains(nodePort)) + foreach (var nodePort in node.Ports) { - count++; + if (nodePort.direction == NodePort.IO.Input) + { + baseIndex++; - continue; - } + continue; + } - //list after May exist dynamic node so break - break; + break; + } + + baseIndex++; } - - index += count; - newIndex += count; + + index += baseIndex; + newIndex += baseIndex; keys.MoveArrayElement(index, newIndex); values.MoveArrayElement(index, newIndex); + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(node); + serializedObject.Update(); + NodeEditorWindow.current.Repaint(); + EditorApplication.delayCall += NodeEditorWindow.current.Repaint; + foreach (NodePort port in reorderableList.list) + { + port.RefreshValueType(); + } }; list.onAddCallback =