mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Added automatic drawing of instance ports
Fixed minor issue getting parentType twice
This commit is contained in:
parent
43038cfcc1
commit
2939fe4935
@ -52,6 +52,7 @@ namespace XNodeEditor {
|
|||||||
string[] excludes = { "m_Script", "graph", "position", "ports" };
|
string[] excludes = { "m_Script", "graph", "position", "ports" };
|
||||||
portPositions = new Dictionary<XNode.NodePort, Vector2>();
|
portPositions = new Dictionary<XNode.NodePort, Vector2>();
|
||||||
|
|
||||||
|
// Iterate through serialized properties and draw them like the Inspector (But with ports)
|
||||||
SerializedProperty iterator = serializedObject.GetIterator();
|
SerializedProperty iterator = serializedObject.GetIterator();
|
||||||
bool enterChildren = true;
|
bool enterChildren = true;
|
||||||
EditorGUIUtility.labelWidth = 84;
|
EditorGUIUtility.labelWidth = 84;
|
||||||
@ -60,6 +61,12 @@ namespace XNodeEditor {
|
|||||||
if (excludes.Contains(iterator.name)) continue;
|
if (excludes.Contains(iterator.name)) continue;
|
||||||
NodeEditorGUILayout.PropertyField(iterator, true);
|
NodeEditorGUILayout.PropertyField(iterator, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate through instance ports and draw them in the order in which they are serialized
|
||||||
|
foreach(XNode.NodePort instancePort in target.InstancePorts) {
|
||||||
|
NodeEditorGUILayout.PortField(instancePort);
|
||||||
|
}
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -154,7 +154,7 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
private static System.Type GetType(SerializedProperty property) {
|
private static System.Type GetType(SerializedProperty property) {
|
||||||
System.Type parentType = property.serializedObject.targetObject.GetType();
|
System.Type parentType = property.serializedObject.targetObject.GetType();
|
||||||
System.Reflection.FieldInfo fi = NodeEditorWindow.GetFieldInfo(property.serializedObject.targetObject.GetType(), property.name);
|
System.Reflection.FieldInfo fi = NodeEditorWindow.GetFieldInfo(parentType, property.name);
|
||||||
return fi.FieldType;
|
return fi.FieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user