From cf3bde96d014d81fb840c556234d52b924909636 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Sun, 15 Oct 2017 18:42:58 +0200 Subject: [PATCH] PropertyField: Better handling of null values --- Scripts/Editor/NodeEditorGUILayout.cs | 26 +++++++++++++------------- Scripts/NodePort.cs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 522f352..aa008de 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -69,19 +69,19 @@ public class NodeEditorGUILayout { } public static object PropertyField(string label, object value, System.Type type) { - if (value is int) return IntField(label, (int) value); - else if (value is float) return FloatField(label, (float) value); - else if (value is double) return DoubleField(label, (double) value); - else if (value is long) return LongField(label, (long) value); - else if (value is bool) return Toggle(label, (bool) value); - else if (value is Enum) return EnumField(label, (Enum) value); - else if (value is string) return TextField(label, (string) value); - else if (value is Rect) return RectField(label, (Rect) value); - else if (value is Vector2) return Vector2Field(label, (Vector2) value); - else if (value is Vector3) return Vector3Field(label, (Vector3) value); - else if (value is Vector4) return Vector4Field(label, (Vector4) value); - else if (value is Color) return ColorField(label, (Color) value); - else if (value is AnimationCurve) return CurveField(label, (AnimationCurve) value); + if (type == typeof(int)) return IntField(label, (int) value); + else if (type == typeof(float)) return FloatField(label, (float) value); + else if (type == typeof(double)) return DoubleField(label, (double) value); + else if (type == typeof(long)) return LongField(label, (long) value); + else if (type == typeof(bool)) return Toggle(label, (bool) value); + else if (type == typeof(Enum)) return EnumField(label, (Enum) value); + else if (type == typeof(string)) return TextField(label, (string) value); + else if (type == typeof(Rect)) return RectField(label, (Rect) value); + else if (type == typeof(Vector2)) return Vector2Field(label, (Vector2) value); + else if (type == typeof(Vector3)) return Vector3Field(label, (Vector3) value); + else if (type == typeof(Vector4)) return Vector4Field(label, (Vector4) value); + else if (type == typeof(Color)) return ColorField(label, (Color) value); + else if (type == typeof(AnimationCurve)) return CurveField(label, (AnimationCurve) value); else if (type.IsSubclassOf(typeof(UnityEngine.Object)) || type == typeof(UnityEngine.Object)) return ObjectField(label, (UnityEngine.Object) value); else return value; } diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index c3b7023..cdcc9c5 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -46,7 +46,7 @@ public class NodePort { /// Checks all connections for invalid references, and removes them. public void VerifyConnections() { - for (int i = connections.Count-1; i >= 0; i--) { + for (int i = connections.Count - 1; i >= 0; i--) { if (connections[i].node != null && !string.IsNullOrEmpty(connections[i].fieldName) && connections[i].node.GetPortByFieldName(connections[i].fieldName) != null)