mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Fixed potential null errors
This commit is contained in:
parent
29b9841014
commit
cb3424d6eb
@ -71,18 +71,18 @@ public class NodeEditorGUILayout {
|
||||
}
|
||||
|
||||
public static object PropertyField(string label, object value, System.Type type) {
|
||||
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(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);
|
||||
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user