1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-21 01:36:03 +08:00

Improved handling of null object fields

This commit is contained in:
Thor 2017-10-20 11:39:11 +02:00
parent 9db84d1608
commit 9dd784d21e

View File

@ -82,7 +82,7 @@ public class NodeEditorGUILayout {
else if (type == typeof(Vector4)) return Vector4Field(label, (Vector4) 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(Color)) return ColorField(label, (Color) value);
else if (type == typeof(AnimationCurve)) return CurveField(label, (AnimationCurve) 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 if (type.IsSubclassOf(typeof(UnityEngine.Object)) || type == typeof(UnityEngine.Object)) return ObjectField(label, (UnityEngine.Object) value, type);
else return value; else return value;
} }
public static Rect GetRect(string label) { public static Rect GetRect(string label) {
@ -92,8 +92,8 @@ public class NodeEditorGUILayout {
rect.x += rect.width; rect.x += rect.width;
return rect; return rect;
} }
public static UnityEngine.Object ObjectField(string label, UnityEngine.Object value) { public static UnityEngine.Object ObjectField(string label, UnityEngine.Object value, Type type) {
return EditorGUI.ObjectField(GetRect(label), value, value.GetType(), true); return EditorGUI.ObjectField(GetRect(label), value, type, true);
} }
public static AnimationCurve CurveField(string label, AnimationCurve value) { public static AnimationCurve CurveField(string label, AnimationCurve value) {
if (value == null) value = new AnimationCurve(); if (value == null) value = new AnimationCurve();