示例#1
0
        public void AddItemsToMenu(GenericMenu menu)
        {
            FR2_Cache api = FR2_Cache.Api;

            if (api == null)
            {
                return;
            }

            menu.AddDisabledItem(new GUIContent("FR2 - v2.4.3"));
            menu.AddSeparator(string.Empty);

            menu.AddItem(new GUIContent("Enable"), !api.disabled, () => { api.disabled = !api.disabled; });

            menu.AddItem(new GUIContent("Clear Selection"), false, () => { FR2_Selection.ClearSelection(); });

            menu.AddItem(new GUIContent("Commit Selection (" + FR2_Selection.SelectionCount + ")"), false,
                         FR2_Selection.Commit);

            menu.AddItem(new GUIContent("Refresh"), false, () =>
            {
                FR2_Asset.lastRefreshTS = Time.realtimeSinceStartup;
                FR2_Cache.Api.Check4Changes(true, true);
                FR2_SceneCache.Api.SetDirty();
            });

#if FR2_DEV
            menu.AddItem(new GUIContent("Refresh Usage"), false, () => FR2_Cache.Api.Check4Usage());
            menu.AddItem(new GUIContent("Refresh Selected"), false, () => FR2_Cache.Api.RefreshSelection());
            menu.AddItem(new GUIContent("Clear Cache"), false, () => FR2_Cache.Api.Clear());
#endif
        }
示例#2
0
        private void DrawGroup(Rect r, string label, int childCount)
        {
            if (FR2_Setting.GroupMode == Mode.Folder)
            {
                Texture tex = AssetDatabase.GetCachedIcon("Assets");
                GUI.DrawTexture(new Rect(r.x - 2f, r.y - 2f, 16f, 16f), tex);
                r.xMin += 16f;
            }

            GUI.Label(r, label + " (" + childCount + ")", EditorStyles.boldLabel);


            bool hasMouse = Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition);

            if (hasMouse && Event.current.button == 1)
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Select"), false, () =>
                {
                    string[] ids = groupDrawer.GetChildren(label);
                    FR2_Selection.ClearSelection();
                    for (var i = 0; i < ids.Length; i++)
                    {
                        FR2_Ref rf;
                        if (!refs.TryGetValue(ids[i], out rf))
                        {
                            continue;
                        }

                        FR2_Selection.AppendSelection(rf);
                    }


                    // FR2_Selection.h.Clear();
                    // for (var i = 0; i < ids.Length; i++)
                    // {
                    //     FR2_Selection.h.Add(ids[i]);
                    // }
                });
                menu.AddItem(new GUIContent("Append Selection"), false, () =>
                {
                    string[] ids = groupDrawer.GetChildren(label);
                    for (var i = 0; i < ids.Length; i++)
                    {
                        FR2_Ref rf;
                        if (!refs.TryGetValue(ids[i], out rf))
                        {
                            continue;
                        }

                        FR2_Selection.AppendSelection(rf);
                    }
                });
                menu.AddItem(new GUIContent("Remove From Selection"), false, () =>
                {
                    string[] ids = groupDrawer.GetChildren(label);
                    for (var i = 0; i < ids.Length; i++)
                    {
                        FR2_Ref rf;
                        if (!refs.TryGetValue(ids[i], out rf))
                        {
                            continue;
                        }

                        FR2_Selection.RemoveSelection(rf);
                        // if (FR2_Selection.h.Contains(ids[i]))
                        // {
                        //     FR2_Selection.h.Remove(ids[i]);
                        // }
                    }
                });

                menu.ShowAsContext();
                Event.current.Use();
            }
        }
示例#3
0
        protected void DrawFooter()
        {
            GUILayout.FlexibleSpace();


            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                Color color = GUI.contentColor;
                GUI.contentColor = EditorGUIUtility.isProSkin
                                        ? new Color(0.9f, 0.9f, 0.9f, 1f)
                                        : new Color(0.1f, 0.1f, 0.1f, 1f);

                if (FR2_Unity.DrawToggleToolbar(ref FR2_Setting.showSettings, Icon.icons.Setting, 21f))
                {
                    maskDirty();
                    if (FR2_Setting.showSettings)
                    {
                        showFilter = showIgnore = false;
                    }
                }

                GUI.contentColor = color;

                bool   v       = checkNoticeFilter();
                string content = !FR2_Setting.IsIncludeAllType() ? "*Filter" : "Filter";
                if (v)
                {
                    Color oc = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;
                    v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f));
                    GUI.backgroundColor = oc;
                }
                else
                {
                    v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f));
                }

                if (v != showFilter)
                {
                    showFilter = v;
                    if (showFilter)
                    {
                        FR2_Setting.showSettings = showIgnore = false;
                    }
                }

                v       = checkNoticeIgnore();
                content = FR2_Setting.IgnoreAsset.Count > 0 ? "*Ignore" : "Ignore";
                if (v)
                {
                    Color oc = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;
                    v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f));
                    GUI.backgroundColor = oc;
                }
                else
                {
                    v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f));
                }

                // var i = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f));
                if (v != showIgnore)
                {
                    showIgnore = v;
                    if (v)
                    {
                        showFilter = FR2_Setting.showSettings = false;
                    }
                }

                bool ss = FR2_Setting.ShowSelection;
                v = GUILayout.Toggle(ss, "Selection", EditorStyles.toolbarButton, GUILayout.Width(60f));
                if (v != ss)
                {
                    FR2_Setting.ShowSelection = v;
                    maskDirty();
                }

                if (FR2_Selection.SelectionCount > 0)
                {
                    if (GUILayout.Button("Commit Selection [" + FR2_Selection.SelectionCount + "]",
                                         EditorStyles.toolbarButton))
                    {
                        FR2_Selection.Commit();
                    }

                    if (GUILayout.Button("Clear Selection", EditorStyles.toolbarButton))
                    {
                        FR2_Selection.ClearSelection();
                    }
                }


                GUILayout.FlexibleSpace();


                if (!IsFocusingDuplicate && !IsFocusingGUIDs)
                {
                    float o = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 42f;

                    FR2_RefDrawer.Mode ov = FR2_Setting.GroupMode;
                    var vv = (FR2_RefDrawer.Mode)EditorGUILayout.EnumPopup("Group", ov, GUILayout.Width(122f));
                    if (vv != ov)
                    {
                        FR2_Setting.GroupMode = vv;
                        maskDirty();
                    }

                    GUILayout.Space(4f);
                    EditorGUIUtility.labelWidth = 30f;

                    FR2_RefDrawer.Sort s = FR2_Setting.SortMode;
                    var vvv = (FR2_RefDrawer.Sort)EditorGUILayout.EnumPopup("Sort", s, GUILayout.Width(100f));
                    if (vvv != s)
                    {
                        FR2_Setting.SortMode = vvv;
                        RefreshSort();
                    }

                    EditorGUIUtility.labelWidth = o;
                }
            }

            GUILayout.EndHorizontal();
        }