diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs
index 301654a..1886295 100644
--- a/Scripts/Editor/NodeEditorGUILayout.cs
+++ b/Scripts/Editor/NodeEditorGUILayout.cs
@@ -3,12 +3,15 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
+using UnityEditorInternal;
using UnityEngine;
namespace XNodeEditor {
/// xNode-specific version of
public static class NodeEditorGUILayout {
+ private static readonly Dictionary> reorderableListCache = new Dictionary>();
+
/// Make a field for a serialized property. Automatically displays relevant node port.
public static void PropertyField(SerializedProperty property, bool includeChildren = true, params GUILayoutOption[] options) {
PropertyField(property, (GUIContent) null, includeChildren, options);
@@ -245,6 +248,34 @@ namespace XNodeEditor {
};
List instancePorts = node.InstancePorts.Where(x => isMatchingInstancePort(x.fieldName)).OrderBy(x => x.fieldName).ToList();
+ ReorderableList list = null;
+ Dictionary rlc;
+ if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) {
+ if (!rlc.TryGetValue(fieldName, out list)) list = null;
+ }
+ if (list == null) {
+ Debug.Log("Create List");
+ list = new ReorderableList(instancePorts, null, true, true, true, true);
+ if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list);
+ else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } });
+ list.drawElementCallback =
+ (Rect rect, int index, bool isActive, bool isFocused) => {
+ XNode.NodePort port = list.list[index] as XNode.NodePort;
+ //SerializedProperty element = serializedObject.get(index);
+ if (hasArrayData) {
+ SerializedProperty itemData = arrayData.GetArrayElementAtIndex(index);
+ EditorGUI.PropertyField(rect, itemData);
+ } else EditorGUI.LabelField(rect, port.fieldName);
+ NodeEditorGUILayout.PortField(node.GetPort(instancePorts[index].fieldName));
+ };
+ list.onReorderCallback =
+ (ReorderableList rl) => {
+
+ };
+ }
+ list.list = instancePorts;
+ list.DoLayoutList();
+
for (int i = 0; i < instancePorts.Count(); i++) {
GUILayout.BeginHorizontal();
// 'Remove' button