mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Fixed #124 - Errors on DynamicPortList with >10 items
Was using OrderBy(x => x.fieldName). The resulting order would then be 1, 10, 11, .. , 2, 3, 4, etc. Fixed by parsing the indices as ints, and ordering by that value instead
This commit is contained in:
parent
2f4adadb72
commit
af0523db2d
@ -275,13 +275,17 @@ namespace XNodeEditor {
|
|||||||
public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action<ReorderableList> onCreation = null) {
|
public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action<ReorderableList> onCreation = null) {
|
||||||
XNode.Node node = serializedObject.targetObject as XNode.Node;
|
XNode.Node node = serializedObject.targetObject as XNode.Node;
|
||||||
|
|
||||||
Predicate<string> isMatchingInstancePort =
|
var indexedPorts = node.InstancePorts.Select(x => {
|
||||||
x => {
|
string[] split = x.fieldName.Split(' ');
|
||||||
string[] split = x.Split(' ');
|
if (split != null && split.Length == 2 && split[0] == fieldName) {
|
||||||
if (split != null && split.Length == 2) return split[0] == fieldName;
|
int i = -1;
|
||||||
else return false;
|
if (int.TryParse(split[1], out i)) {
|
||||||
};
|
return new { index = i, port = x };
|
||||||
List<XNode.NodePort> instancePorts = node.InstancePorts.Where(x => isMatchingInstancePort(x.fieldName)).OrderBy(x => x.fieldName).ToList();
|
}
|
||||||
|
}
|
||||||
|
return new { index = -1, port = (XNode.NodePort) null };
|
||||||
|
});
|
||||||
|
List<XNode.NodePort> instancePorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();
|
||||||
|
|
||||||
ReorderableList list = null;
|
ReorderableList list = null;
|
||||||
Dictionary<string, ReorderableList> rlc;
|
Dictionary<string, ReorderableList> rlc;
|
||||||
@ -400,13 +404,17 @@ namespace XNodeEditor {
|
|||||||
list.onRemoveCallback =
|
list.onRemoveCallback =
|
||||||
(ReorderableList rl) => {
|
(ReorderableList rl) => {
|
||||||
|
|
||||||
Predicate<string> isMatchingInstancePort =
|
var indexedPorts = node.InstancePorts.Select(x => {
|
||||||
x => {
|
string[] split = x.fieldName.Split(' ');
|
||||||
string[] split = x.Split(' ');
|
if (split != null && split.Length == 2 && split[0] == fieldName) {
|
||||||
if (split != null && split.Length == 2) return split[0] == fieldName;
|
int i = -1;
|
||||||
else return false;
|
if (int.TryParse(split[1], out i)) {
|
||||||
};
|
return new { index = i, port = x };
|
||||||
instancePorts = node.InstancePorts.Where(x => isMatchingInstancePort(x.fieldName)).OrderBy(x => x.fieldName).ToList();
|
}
|
||||||
|
}
|
||||||
|
return new { index = -1, port = (XNode.NodePort) null };
|
||||||
|
});
|
||||||
|
instancePorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList();
|
||||||
|
|
||||||
int index = rl.index;
|
int index = rl.index;
|
||||||
// Clear the removed ports connections
|
// Clear the removed ports connections
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user