1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 09:16:01 +08:00

Nodes now show unsupported value types as labels.

This commit is contained in:
Thor Kramer Brigsted 2017-10-31 11:25:49 +01:00
parent eaeca48f69
commit f335ecfbb5
2 changed files with 16 additions and 16 deletions

View File

@ -31,7 +31,7 @@ public class NodeEditor {
EditorGUI.BeginChangeCheck();
FieldInfo[] fields = GetInspectorFields(target);
for (int i = 0; i < fields.Length; i++) {
if (fields[i].Name == "graph" || fields[i].Name == "position") continue;
switch (fields[i].Name) { case "graph": case "position": case "inputs": case "outputs": continue; }
NodeEditorGUILayout.PropertyField(target, fields[i], portPositions);
}
//If user changed a value, notify other scripts through onUpdateNode

View File

@ -71,21 +71,21 @@ public class NodeEditorGUILayout {
}
public static object PropertyField(string label, object value, System.Type type) {
if (type == typeof(int)) return IntField(label, value is int ? (int) value : default(int));
else if (type == typeof(float)) return FloatField(label, value is float ? (float) value : default(float));
else if (type == typeof(double)) return DoubleField(label, value is double ? (double) value : default(double));
else if (type == typeof(long)) return LongField(label, value is long ? (long) value : default(long));
else if (type == typeof(bool)) return Toggle(label, value is bool ? (bool) value : default(bool));
else if (type == typeof(string)) return TextField(label, value is string ? (string) value : default(string));
else if (type == typeof(Rect)) return RectField(label, value is Rect ? (Rect) value : default(Rect));
else if (type == typeof(Vector2)) return Vector2Field(label, value is Vector2 ? (Vector2) value : default(Vector2));
else if (type == typeof(Vector3)) return Vector3Field(label, value is Vector3 ? (Vector3) value : default(Vector3));
else if (type == typeof(Vector4)) return Vector4Field(label, value is Vector4 ? (Vector4) value : default(Vector4));
else if (type == typeof(Color)) return ColorField(label, value is Color ? (Color) value : default(Color));
else if (type == typeof(AnimationCurve)) return CurveField(label, value is AnimationCurve ? (AnimationCurve) value : default(AnimationCurve));
else if (type.IsSubclassOf(typeof(Enum)) || type == typeof(Enum)) return EnumField(label, (Enum) value);
else if (type.IsSubclassOf(typeof(UnityEngine.Object)) || type == typeof(UnityEngine.Object)) return ObjectField(label, (UnityEngine.Object) value, type);
else return value;
if (type == typeof(int)) return IntField(label, value is int ? (int)value : default(int));
else if (type == typeof(float)) return FloatField(label, value is float ? (float)value : default(float));
else if (type == typeof(double)) return DoubleField(label, value is double ? (double)value : default(double));
else if (type == typeof(long)) return LongField(label, value is long ? (long)value : default(long));
else if (type == typeof(bool)) return Toggle(label, value is bool ? (bool)value : default(bool));
else if (type == typeof(string)) return TextField(label, value is string ? (string)value : default(string));
else if (type == typeof(Rect)) return RectField(label, value is Rect ? (Rect)value : default(Rect));
else if (type == typeof(Vector2)) return Vector2Field(label, value is Vector2 ? (Vector2)value : default(Vector2));
else if (type == typeof(Vector3)) return Vector3Field(label, value is Vector3 ? (Vector3)value : default(Vector3));
else if (type == typeof(Vector4)) return Vector4Field(label, value is Vector4 ? (Vector4)value : default(Vector4));
else if (type == typeof(Color)) return ColorField(label, value is Color ? (Color)value : default(Color));
else if (type == typeof(AnimationCurve)) return CurveField(label, value is AnimationCurve ? (AnimationCurve)value : default(AnimationCurve));
else if (type.IsSubclassOf(typeof(Enum)) || type == typeof(Enum)) return EnumField(label, (Enum)value);
else if (type.IsSubclassOf(typeof(UnityEngine.Object)) || type == typeof(UnityEngine.Object)) return ObjectField(label, (UnityEngine.Object)value, type);
else { GUILayout.Label(label); return value; }
}
public static Rect GetRect(string label) {
Rect rect = EditorGUILayout.GetControlRect();