1
0
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:
Thor Brigsted 2019-03-02 11:53:48 +01:00
parent 43038cfcc1
commit 2939fe4935
2 changed files with 8 additions and 1 deletions

View File

@ -52,6 +52,7 @@ namespace XNodeEditor {
string[] excludes = { "m_Script", "graph", "position", "ports" };
portPositions = new Dictionary<XNode.NodePort, Vector2>();
// Iterate through serialized properties and draw them like the Inspector (But with ports)
SerializedProperty iterator = serializedObject.GetIterator();
bool enterChildren = true;
EditorGUIUtility.labelWidth = 84;
@ -60,6 +61,12 @@ namespace XNodeEditor {
if (excludes.Contains(iterator.name)) continue;
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();
}

View File

@ -154,7 +154,7 @@ namespace XNodeEditor {
private static System.Type GetType(SerializedProperty property) {
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;
}