diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs
index 6129dd8..7c5800e 100644
--- a/Scripts/Editor/NodeEditorGUILayout.cs
+++ b/Scripts/Editor/NodeEditorGUILayout.cs
@@ -11,8 +11,6 @@ namespace XNodeEditor {
/// xNode-specific version of
public static class NodeEditorGUILayout {
- /// Listen for this event if you want to alter the default ReorderableList
- public static Action onCreateReorderableList;
private static readonly Dictionary> reorderableListCache = new Dictionary>();
private static int reorderableListIndex = -1;
@@ -256,17 +254,13 @@ namespace XNodeEditor {
GUI.color = col;
}
- [Obsolete("Use InstancePortList(string, Type, SerializedObject, NodePort.IO, Node.ConnectionType) instead")]
- public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple) {
- InstancePortList(fieldName, type, serializedObject, XNode.NodePort.IO.Output, connectionType);
- }
-
/// Draw an editable list of instance ports. Port names are named as "[fieldName] [index]"
/// Supply a list for editable values
/// Value type of added instance ports
/// The serializedObject of the node
/// Connection type of added instance ports
- public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple) {
+ /// Called on the list on creation. Use this if you want to customize the created ReorderableList
+ public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, Action onCreation = null) {
XNode.Node node = serializedObject.targetObject as XNode.Node;
SerializedProperty arrayData = serializedObject.FindProperty(fieldName);
@@ -286,7 +280,7 @@ namespace XNodeEditor {
// If a ReorderableList isn't cached for this array, do so.
if (list == null) {
string label = serializedObject.FindProperty(fieldName).displayName;
- list = CreateReorderableList(instancePorts, arrayData, type, serializedObject, io, label, connectionType);
+ list = CreateReorderableList(instancePorts, arrayData, type, serializedObject, io, label, connectionType, onCreation);
if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list);
else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } });
}
@@ -294,7 +288,7 @@ namespace XNodeEditor {
list.DoLayoutList();
}
- private static ReorderableList CreateReorderableList(List instancePorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, string label, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple) {
+ private static ReorderableList CreateReorderableList(List instancePorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, string label, XNode.Node.ConnectionType connectionType, Action onCreation) {
bool hasArrayData = arrayData != null && arrayData.isArray;
int arraySize = hasArrayData ? arrayData.arraySize : 0;
XNode.Node node = serializedObject.targetObject as XNode.Node;
@@ -324,7 +318,7 @@ namespace XNodeEditor {
};
list.drawHeaderCallback =
(Rect rect) => {
- EditorGUI.LabelField(rect, label);
+ EditorGUI.LabelField(rect, label + "(" + serializedObject.targetObject.name + ")");
};
list.onSelectCallback =
(ReorderableList rl) => {
@@ -413,7 +407,7 @@ namespace XNodeEditor {
while (instancePorts.Count <= arraySize) {
arrayData.DeleteArrayElementAtIndex(--arraySize);
}
- Debug.LogWarning("Array size exceeded instance ports size. Excess items removed.");
+ UnityEngine.Debug.LogWarning("Array size exceeded instance ports size. Excess items removed.");
}
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
@@ -440,7 +434,7 @@ namespace XNodeEditor {
serializedObject.ApplyModifiedProperties();
serializedObject.Update();
}
- if (onCreateReorderableList != null) onCreateReorderableList(list);
+ if (onCreation != null) onCreation(list);
return list;
}
}