Example #1
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 = DrawerFactory.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 = DrawerFactory.GetObjectDrawer(t);

            return(objectDrawer.DrawGUI(content, value, field, context, drawerAttributes));
        }
		///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
			if (field != null && attributes != null){
				var drawerAttributes = attributes.OfType<DrawerAttribute>().OrderBy(a => a.priority).ToArray();
				var drawer = DrawerFactory.GetObjectDrawer(t);
				return drawer.DrawGUI(content, value, field, context, drawerAttributes);
			}
		
			return DrawEditorFieldDirect(content, value, t, field, context, attributes);
		}