From 77b4c034bf512b11d827a14ce91d253162bad564 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 1 Apr 2019 18:40:19 +0200 Subject: [PATCH] Uncommitted stuff --- Scripts/Editor/NodeEditorGUILayout.cs | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 7cc1a21..8a81423 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -385,20 +385,26 @@ namespace XNodeEditor { list.onRemoveCallback = (ReorderableList rl) => { int index = rl.index; - // Clear the removed ports connections - instancePorts[index].ClearConnections(); - // Move following connections one step up to replace the missing connection - for (int k = index + 1; k < instancePorts.Count(); k++) { - for (int j = 0; j < instancePorts[k].ConnectionCount; j++) { - XNode.NodePort other = instancePorts[k].GetConnection(j); - instancePorts[k].Disconnect(other); - instancePorts[k - 1].Connect(other); + + if (instancePorts.Count > index) { + // Clear the removed ports connections + instancePorts[index].ClearConnections(); + // Move following connections one step up to replace the missing connection + for (int k = index + 1; k < instancePorts.Count(); k++) { + for (int j = 0; j < instancePorts[k].ConnectionCount; j++) { + XNode.NodePort other = instancePorts[k].GetConnection(j); + instancePorts[k].Disconnect(other); + instancePorts[k - 1].Connect(other); + } } + // Remove the last instance port, to avoid messing up the indexing + node.RemoveInstancePort(instancePorts[instancePorts.Count() - 1].fieldName); + serializedObject.Update(); + EditorUtility.SetDirty(node); + } else { + Debug.LogWarning("InstancePorts[" + index + "] out of range. Length was " + instancePorts.Count + ". Skipping."); } - // Remove the last instance port, to avoid messing up the indexing - node.RemoveInstancePort(instancePorts[instancePorts.Count() - 1].fieldName); - serializedObject.Update(); - EditorUtility.SetDirty(node); + if (hasArrayData) { arrayData.DeleteArrayElementAtIndex(index); arraySize--;