///<summary>Draws an Editor field for object of type directly WITHOUT taking into acount object drawers and drawer attributes unless provided</summary> public static object DrawEditorFieldDirect(GUIContent content, object value, Type t, InspectedFieldInfo info) { ///---------------------------------------------------------------------------------------------- bool handled; var newValue = DirectFieldControl(content, value, t, info.unityObjectContext, info.attributes, out handled); var changed = !object.Equals(newValue, value); if (changed) { UndoUtility.RecordObjectComplete(info.unityObjectContext, content.text + "Field Change"); } value = newValue; if (changed) { UndoUtility.SetDirty(info.unityObjectContext); } if (handled) { return(value); } ///---------------------------------------------------------------------------------------------- if (typeof(IList).IsAssignableFrom(t)) { return(ListEditor(content, (IList)value, t, info)); } if (typeof(IDictionary).IsAssignableFrom(t)) { return(DictionaryEditor(content, (IDictionary)value, t, info)); } //show nested class members recursively, avoid all collections not handles above manually if (value != null && (t.IsClass || t.IsValueType) && !typeof(ICollection).IsAssignableFrom(t)) { if (EditorGUI.indentLevel <= 8) { if (!CachedFoldout(t, content)) { return(value); } EditorGUI.indentLevel++; ReflectedObjectInspector(value, info.unityObjectContext); EditorGUI.indentLevel--; } } else { EditorGUILayout.LabelField(content, GetTempContent(string.Format("NonInspectable ({0})", t.FriendlyName()))); } return(value); }
///<summary>Draws an Editor field for object of type directly WITH taking into acount object drawers and drawer attributes</summary> public static object ReflectedFieldInspector(GUIContent content, object value, Type t, InspectedFieldInfo info) { if (t == null) { GUILayout.Label("NO TYPE PROVIDED!"); return(value); } //Use drawers var objectDrawer = PropertyDrawerFactory.GetObjectDrawer(t); var newValue = objectDrawer.DrawGUI(content, value, info); var changed = !object.Equals(newValue, value); if (changed) { UndoUtility.RecordObjectComplete(info.unityObjectContext, content.text + "Field Change"); } value = newValue; if (changed) { UndoUtility.SetDirty(info.unityObjectContext); } return(value); }