/// <summary> /// Returns a display action for the value. /// </summary> /// <param name="value">Value to be displayed</param> /// <param name="defaultString">default string for the value</param> private static Action DisplayFieldFor(object value, string defaultString) { if (value == null) { return(() => EditorGUILayout.SelectableLabel(defaultString, GUI.skin.textField, GUILayout.ExpandWidth(true), GUILayout.Height(17))); } var type = value.GetType(); if (FieldForType.ContainsKey(type)) { return(() => FieldForType[type](value)); } if (type.IsEnum) { return(() => EditorGUILayout.EnumPopup((Enum)value)); } else if (value is UnityEngine.Object) { return(() => EditorGUILayout.ObjectField(value as UnityEngine.Object, type, allowSceneObjects: true)); } else { return(() => EditorGUILayout.SelectableLabel(defaultString, GUI.skin.textField, GUILayout.ExpandWidth(true), GUILayout.Height(17))); } }
private static bool NeedsSpecialField(Type type) { return(FieldForType.ContainsKey(type) || type == typeof(UnityEngine.Object)); }