Exemplo n.º 1
0
            public void Setup(string setLabel, OnActivateItem setEffect, bool setOn)
            {
                label = GUIContentPool.Create(setLabel);

                effect = setEffect;
                on     = setOn;
            }
Exemplo n.º 2
0
        public void DrawBreakdownMenu()
        {
            GenericMenu  menu          = new GenericMenu();
            MenuFunction hideBreakdown = () => { StateBehaviourEditor.isVisible = false; };

            menu.AddItem(new GUIContent("Settings/Hide"), false, hideBreakdown);
            menu.ShowAsContext();
        }
Exemplo n.º 3
0
 public void DrawContext()
 {
     if (this.position.SetX(0).SetY(0).Clicked(1))
     {
         GenericMenu  menu    = new GenericMenu();
         MenuFunction refresh = () => { this.Reset(); };
         menu.AddItem(new GUIContent("Refresh"), false, refresh);
         menu.ShowAsContext();
     }
 }
Exemplo n.º 4
0
        public static ItemInfo Item(string label, OnActivateItem effect)
        {
            ItemInfo item;

            if (!ItemPool.TryGet(out item))
            {
                item = new ItemInfo();
            }
            item.Setup(label, effect);
            return(item);
        }
Exemplo n.º 5
0
        public static ItemInfo Item(string label, string tooltip, OnActivateItem effect, bool on)
        {
            ItemInfo item;

            if (!ItemPool.TryGet(out item))
            {
                item = new ItemInfo();
            }
            item.Setup(label, tooltip, effect, on);
            return(item);
        }
Exemplo n.º 6
0
        public void AddItem(GUIContent content, bool on, MenuFunction func)
        {
#if UNITY_EDITOR
            if (editorMenu != null)
            {
                editorMenu.AddItem(content, on, func);
            }
            else
#endif
            popup.AddItem(content, on, func);
        }
Exemplo n.º 7
0
        public void AddItem(GUIContent content, bool on, MenuFunction func)
        {
            string   path;
            MenuItem parent = AddHierarchy(ref content, out path);

            if (parent != null)
            {
                parent.subItems.Add(new MenuItem(path, content, func));
            }
            else
            {
                menuItems.Add(new MenuItem(path, content, func));
            }
        }
Exemplo n.º 8
0
        public virtual void DrawAddMenu()
        {
            this.contextOpen = true;
            GenericMenu menu = new GenericMenu();

            foreach (Type attributeType in this.attribute.GetFormulaTypes())
            {
                string       name    = attributeType.Name.Remove("Attribute", "Data");
                string       set     = this.attribute.defaultSet;
                MethodInfo   generic = this.attribute.GetType().GetMethod("Add", new Type[] { typeof(int), typeof(string) }).MakeGenericMethod(attributeType);
                MenuFunction method  = () => { generic.Invoke(this.attribute, new object[] { -1, set }); };
                menu.AddItem(new GUIContent(name), false, method);
            }
            menu.ShowAsContext();
        }
Exemplo n.º 9
0
            public void Dispose()
            {
                if (label == GUIContent.none)
                {
                    label = null;
                }
                else
                {
                    GUIContentPool.Dispose(ref label);
                }

                methodOwner          = null;
                on                   = false;
                effect               = null;
                effectWithParameter  = null;
                effectParameterValue = null;
                isSeparator          = false;
            }
Exemplo n.º 10
0
        public void DrawMenu()
        {
            GenericMenu  menu              = new GenericMenu();
            MenuFunction toggleAdvanced    = () => EditorPref.Toggle("MonoBehaviourEditor-Advanced");
            MenuFunction toggleInternal    = () => EditorPref.Toggle("MonoBehaviourEditor-Internal");
            MenuFunction toggleDictionary  = () => EditorPref.Toggle("MonoBehaviourEditor-Dictionary");
            MenuFunction hideAllDefaults   = () => EditorPref.Toggle("MonoBehaviourEditor-HideAllDefault");
            MenuFunction hideLocalDefaults = () => {
                this.hideDefault = !this.hideDefault;
                EditorPref.Set <bool>("MonoBehaviourEditor-" + this.target.GetInstanceID() + "HideDefault", this.hideDefault);
            };

            menu.AddItem(new GUIContent("Advanced"), EditorPref.Get <bool>("MonoBehaviourEditor-Advanced"), toggleAdvanced);
            menu.AddItem(new GUIContent("Internal"), EditorPref.Get <bool>("MonoBehaviourEditor-Internal"), toggleInternal);
            menu.AddItem(new GUIContent("Dictionary"), EditorPref.Get <bool>("MonoBehaviourEditor-Dictionary"), toggleDictionary);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Defaults/Hide All"), EditorPref.Get <bool>("MonoBehaviourEditor-HideAllDefault"), hideAllDefaults);
            menu.AddItem(new GUIContent("Defaults/Hide Local"), this.hideDefault, hideLocalDefaults);
            if (this.hidden.Count > 0)
            {
                MenuFunction unhideAll = () => {
                    foreach (var property in this.hidden)
                    {
                        string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
                        EditorPref.Set <bool>(path, false);
                    }
                    this.hidden.Clear();
                };
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Unhide/All"), false, unhideAll);
                foreach (var property in this.hidden)
                {
                    SerializedProperty target = property;
                    MenuFunction       unhide = () => {
                        string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
                        EditorPref.Set <bool>(path, false);
                        this.hidden.Remove(target);
                    };
                    menu.AddItem(new GUIContent("Unhide/" + property.displayName), false, unhide);
                }
            }
            menu.ShowAsContext();
            Event.current.Use();
        }
Exemplo n.º 11
0
 private void GenerateActionsUsingRefection(string methodName, FieldInfo field = null)
 {
     if (methodOwner != null)
     {
         var             method     = methodOwner.GetType().GetMethod(methodName);
         ParameterInfo[] parameters = method.GetParameters();
         if (parameters.Length == 0)
         {
             effect = () => method.Invoke(methodOwner, null);
         }
         else
         {
             if (field != null)
             {
                 effect = () => method.InvokeWithParameter(methodOwner, field.GetValue(methodOwner));
             }
             else
             {
                 effect = () => method.InvokeWithParameter(methodOwner, parameters[0].ParameterType.DefaultValue());
             }
         }
     }
 }
Exemplo n.º 12
0
        public virtual void DrawTypeMenu(AttributeData data, GenericMenu menu = null)
        {
            bool openMenu = menu == null;

            menu = menu ?? new GenericMenu();
            Type[] types = this.attribute.GetFormulaTypes();
            if (types.Length > 0)
            {
                int index = this.activeDataset.IndexOf(data);
                foreach (Type attributeType in types)
                {
                    Type         type     = attributeType;
                    string       name     = type.Name.Remove("Attribute", "Data");
                    string       set      = this.attribute.defaultSet;
                    MenuFunction swapType = () => { this.SwapType(index, type, set); };
                    menu.AddItem(new GUIContent("Type/" + name), (data.GetType() == type), swapType);
                }
            }
            if (openMenu)
            {
                menu.ShowAsContext();
            }
        }
Exemplo n.º 13
0
        public override void Clicked(int button)
        {
            var window = StateWindow.Get();

            if (button == 0)
            {
                if (window.target.advanced)
                {
                    window.tableIndex = window.tableIndex == 0 ? 1 : 0;
                    window.BuildTable();
                }
            }
            if (button == 1)
            {
                var          menu           = new GenericMenu();
                MenuFunction markDirty      = () => ProxyEditor.SetDirty(window.target);
                MenuFunction toggleAdvanced = () => {
                    ProxyEditor.RecordObject(window.target, "State Window - Advanced Toggle");
                    window.target.advanced = !window.target.advanced;
                    window.tableIndex      = 0;
                    window.BuildTable();
                };
                MenuFunction toggleManual = () => {
                    ProxyEditor.RecordObject(window.target, "State Window - Manual Toggle");
                    window.target.manual = !window.target.manual;
                    window.BuildTable();
                };
                menu.AddItem("Advanced", window.target.advanced, toggleAdvanced + markDirty);
                if (window.target.controller != null)
                {
                    menu.AddItem("Manual", window.target.manual, toggleManual + markDirty);
                }
                menu.AddItem("Rebuild", false, window.BuildTable);
                menu.ShowAsContext();
            }
        }
Exemplo n.º 14
0
 public void DrawShaders()
 {
     EditorGUI.indentLevel += 1;
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical(this.labelWidth);
     for (int index = 0; index < this.shaders.Length; ++index)
     {
         this.shaders[index] = this.shaders[index].Draw <Shader>((index + 1).ToString(), false, true);
     }
     GUILayout.EndVertical();
     GUILayout.BeginVertical(this.labelWidth);
     this.goal = this.goal.Draw <Shader>("Goal");
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
     EditorGUI.indentLevel -= 1;
     if (GUILayoutUtility.GetLastRect().Clicked(1))
     {
         GenericMenu  menu     = new GenericMenu();
         MenuFunction loadUsed = () => this.LoadUsed();
         menu.AddItem(new GUIContent("Load Used Shaders"), false, loadUsed);
         menu.ShowAsContext();
         Event.current.Use();
     }
 }
Exemplo n.º 15
0
 public void AddEvenIfDuplicate(string label, string tooltip, OnActivateItem effect, bool on)
 {
     Add(Item(MakeUniqueLabel(label), tooltip, effect, on));
 }
Exemplo n.º 16
0
 public MenuItem(string _path, GUIContent _content, MenuFunction _func)
 {
     path    = _path;
     content = _content;
     func    = _func;
 }
Exemplo n.º 17
0
 public virtual void DrawContext(AttributeData data, bool showRemove = false, bool isRoot = true)
 {
     if (this.labelRect.AddWidth(20).Clicked(1))
     {
         this.contextOpen = true;
         GenericMenu    menu            = new GenericMenu();
         AttributeMode  mode            = this.attribute.info.mode;
         AttributeUsage usage           = data.usage;
         bool           advanced        = EditorPref.Get <bool>(data.path + "Advanced");
         MenuFunction   toggleAdvanced  = () => { EditorPref.Set <bool>(data.path + "Advanced", !advanced); };
         MenuFunction   removeAttribute = () => { this.attribute.Remove(data); };
         MenuFunction   modeNormal      = () => { this.attribute.info.mode = AttributeMode.Normal; };
         MenuFunction   modeLinked      = () => { this.attribute.info.mode = AttributeMode.Linked; };
         MenuFunction   modeFormula     = () => { this.attribute.info.mode = AttributeMode.Formula; };
         MenuFunction   modeGroup       = () => { this.attribute.info.mode = AttributeMode.Group; };
         MenuFunction   usageDirect     = () => {
             data.usage         = AttributeUsage.Direct;
             data.referencePath = "";
             data.referenceID   = "";
             data.reference     = null;
         };
         MenuFunction usageShaped = () => { data.usage = AttributeUsage.Shaped; };
         MenuFunction fixType     = () => { this.SwapType(0, typeof(DataType), this.attribute.defaultSet); };
         bool         normal      = this.attribute.info.mode == AttributeMode.Normal;
         if (this.attribute.locked)
         {
             menu.AddDisabledItem(new GUIContent("Attribute Locked"));
             menu.ShowAsContext();
             return;
         }
         if (isRoot || mode.Matches("Normal", "Linked"))
         {
             if (mode.Matches("Normal", "Linked") && usage.Matches("Shaped") && this.attribute.canAdvanced)
             {
                 menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced);
                 menu.AddSeparator("/");
             }
             if (this.attribute.canDirect)
             {
                 menu.AddItem(new GUIContent("Direct"), normal && (usage == AttributeUsage.Direct), fixType + modeNormal + usageDirect);
             }
             if (this.attribute.canShape)
             {
                 menu.AddItem(new GUIContent("Shaped"), normal && (usage == AttributeUsage.Shaped), fixType + modeNormal + usageShaped);
             }
             if (this.attribute.canLink)
             {
                 menu.AddItem(new GUIContent("Linked"), (mode == AttributeMode.Linked), fixType + modeLinked + usageShaped);
             }
             menu.AddSeparator("/");
             if (this.attribute.canFormula)
             {
                 menu.AddItem(new GUIContent("Formula"), (mode == AttributeMode.Formula), modeFormula);
             }
             if (this.attribute.canGroup)
             {
                 menu.AddItem(new GUIContent("Group"), (mode == AttributeMode.Group), modeGroup);
             }
         }
         else if (mode.Matches("Formula"))
         {
             menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced);
             this.DrawTypeMenu(data, menu);
             menu.AddSeparator("/");
             if (this.attribute.canDirect)
             {
                 menu.AddItem(new GUIContent("Direct"), usage == AttributeUsage.Direct, usageDirect);
             }
             if (this.attribute.canShape)
             {
                 menu.AddItem(new GUIContent("Shaped"), usage == AttributeUsage.Shaped, usageShaped);
             }
         }
         if (showRemove)
         {
             if (!mode.Matches("Group"))
             {
                 menu.AddSeparator("/");
             }
             menu.AddItem(new GUIContent("Remove"), false, removeAttribute);
         }
         menu.ShowAsContext();
     }
     if (this.contextOpen && Event.current.button == 0)
     {
         this.dirty       = true;
         this.contextOpen = false;
     }
 }
Exemplo n.º 18
0
 public void Setup(string setLabel, string setTooltip, OnActivateItem setEffect)
 {
     label  = GUIContentPool.Create(setLabel, setTooltip);
     effect = setEffect;
 }
Exemplo n.º 19
0
 public void Insert(int index, string label, OnActivateItem effect, bool on)
 {
     Insert(index, Item(label, effect, on));
 }
Exemplo n.º 20
0
 public void AddEvenIfDuplicate(string label, OnActivateItem effect)
 {
     Add(Item(MakeUniqueLabel(label), effect));
 }
Exemplo n.º 21
0
 public void Add(string label, string tooltip, OnActivateItem effect, bool on)
 {
     Add(Item(label, tooltip, effect, on));
 }
Exemplo n.º 22
0
 public void Add(string label, OnActivateItem effect)
 {
     Add(Item(label, effect));
 }