示例#1
0
 ///Show the next attribute drawer in order, or the object drawer itself of no attribute drawer is left to show.
 object IObjectDrawer.MoveNextDrawer()
 {
     attributeIndex++;
     if (attributes != null && attributeIndex < attributes.Length)
     {
         var currentDrawerAttribute = attributes[attributeIndex];
         var drawer = PropertyDrawerFactory.GetAttributeDrawer(currentDrawerAttribute);
         return(drawer.DrawGUI(this, content, instance, currentDrawerAttribute, info));
     }
     return(OnGUI(content, instance));
 }
示例#2
0
 ///Show the next attribute drawer in order, or the object drawer itself of no attribute drawer is left to show.
 public object MoveNextDrawer()
 {
     attributeIndex++;
     if (attributes != null && attributeIndex < attributes.Length)
     {
         var att    = attributes[attributeIndex];
         var drawer = PropertyDrawerFactory.GetAttributeDrawer(att);
         return(drawer.DrawGUI(this, content, instance, fieldInfo, context, att));
     }
     return(OnGUI(content, instance));
 }
        ///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));
        }
示例#4
0
        ///<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);
        }