예제 #1
0
 private void DrawMember(MemberReference member, ShowInInspectorAttribute attribute)
 {
     FlaiGUI.PushGuiEnabled(!attribute.IsReadOnly && (attribute.IsEditableWhenNotPlaying || Application.isPlaying) && member.CanWrite);
     if (!this.TryDrawMember(member, attribute))
     {
         DrawFunction drawFunction;
         if (InternalPropertyDrawer.GetDrawFunction(member, attribute, out drawFunction))
         {
             this.DrawMember(member, attribute, drawFunction);
         }
         else
         {
             var value = member.GetValue(this.Target);
             if (value is UnityObject) // simple special case.. not sure what I needed this for though... :|
             {
                 this.DrawMember(member, attribute, (n, v, o) => EditorGUILayout.ObjectField(n, (UnityObject)v, typeof(UnityObject), true));
             }
             else
             {
                 FlaiGUI.PushGuiEnabled(false);
                 this.DrawMember(member, attribute,
                                 (n, v, o) => EditorGUILayout.TextField(n + " (unkown type)", (v == null) ? "" : v.ToString()), true);
                 FlaiGUI.PopGuiEnabled();
             }
         }
     }
     FlaiGUI.PopGuiEnabled();
 }
예제 #2
0
        private void DrawMethod(MethodInfo method, ShowInInspectorAttribute attribute)
        {
            if (method.ContainsGenericParameters || method.GetParameters().Length > 0)
            {
                FlaiDebug.LogWarningWithTypeTag <DefaultInspector>("Method '{0}' has parameters or generic parameters. It cannot be called", method.Name);
                return;
            }

            FlaiGUI.PushGuiEnabled(!attribute.IsReadOnly && (attribute.IsEditableWhenNotPlaying || Application.isPlaying));
            if (GUILayout.Button(this.GetName(method.Name, attribute)))
            {
                method.Invoke(this.Target, null);
            }
            FlaiGUI.PopGuiEnabled();
        }
예제 #3
0
        public static T DrawField <T>(string label, T value, bool isReadOnly = false, params GUILayoutOption[] parameters)
        {
            DrawFunction drawFunction;

            if (InternalPropertyDrawer.GetDrawFunction <T>(out drawFunction))
            {
                FlaiGUI.PushGuiEnabled(!isReadOnly);
                var newValue = (T)drawFunction(label, value, parameters);
                FlaiGUI.PopGuiEnabled();
                return(newValue);
            }

            FlaiGUI.PushGuiEnabled(false);
            EditorGUILayout.TextField(label + "(unknown type)", value.ToString(), parameters);
            FlaiGUI.PopGuiEnabled();
            return(value);
        }