///Show an arbitrary field type editor. Passing a FieldInfo will also check for attributes. public static object ReflectedFieldInspector(GUIContent content, object value, Type t, FieldInfo field = null, object context = null, object[] attributes = null) { if (t == null) { GUILayout.Label("NO TYPE PROVIDED!"); return(value); } ///Use drawers var drawerAttributes = attributes != null?attributes.OfType <DrawerAttribute>().OrderBy(a => a.priority).ToArray() : null; var objectDrawer = PropertyDrawerFactory.GetObjectDrawer(t); return(objectDrawer.DrawGUI(content, value, field, context, drawerAttributes)); }
///<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); }