示例#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
        public void Draw(Rect r, IWindow window)
        {
            bool selected = isSelected();
            var  margin   = 2;
            var  left     = new Rect(r);

            left.width = r.width / 3f;
            var right = new Rect(r);

            right.x    += left.width + margin;
            right.width = r.width * 2f / 3 - margin;

            if (/* FR2_Setting.PingRow && */ Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Rect pingRect = FR2_Setting.PingRow
                                        ? new Rect(0, r.y, r.x + r.width, r.height)
                                        : left;
                if (pingRect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.control || Event.current.command)
                    {
                        if (selected)
                        {
                            FR2_Selection.RemoveSelection(this);
                        }
                        else
                        {
                            FR2_Selection.AppendSelection(this);
                        }

                        if (window != null)
                        {
                            window.Repaint();
                        }
                    }

                    EditorGUIUtility.PingObject(component);
                    //Event.current.Use();
                }
            }


            EditorGUI.ObjectField(left, GUIContent.none, component, typeof(GameObject), true);


            bool   drawPath  = FR2_Setting.GroupMode != FR2_RefDrawer.Mode.Folder;
            float  pathW     = drawPath ? EditorStyles.miniLabel.CalcSize(new GUIContent(scenePath)).x : 0;
            string assetName = component.name;
            // if(usingType!= null && usingType.Count > 0)
            // {
            //  assetName += " -> ";
            //  foreach(var item in usingType)
            //  {
            //      assetName += item + " - ";
            //  }
            //  assetName = assetName.Substring(0, assetName.Length - 3);
            // }
            Color cc = FR2_Cache.Api.setting.SelectedColor;

            var lableRect = new Rect(
                right.x,
                right.y,
                pathW + EditorStyles.boldLabel.CalcSize(new GUIContent(assetName)).x,
                right.height);

            if (selected)
            {
                Color c = GUI.color;
                GUI.color = cc;
                GUI.DrawTexture(lableRect, EditorGUIUtility.whiteTexture);
                GUI.color = c;
            }

            if (drawPath)
            {
                GUI.Label(LeftRect(pathW, ref right), scenePath, EditorStyles.miniLabel);
                right.xMin -= 4f;
                GUI.Label(right, assetName, EditorStyles.boldLabel);
            }
            else
            {
                GUI.Label(right, assetName);
            }


            if (!FR2_Setting.ShowUsedByClassed || usingType == null)
            {
                return;
            }

            float sub = 10;
            var   re  = new Rect(r.x + r.width - sub, r.y, 20, r.height);
            Type  t   = null;

            foreach (string item in usingType)
            {
                string name = item;
                if (!CacheType.TryGetValue(item, out t))
                {
                    t = FR2_Unity.GetType(name);
                    // if (t == null)
                    // {
                    //  continue;
                    // }
                    CacheType.Add(item, t);
                }

                GUIContent content;
                var        width = 0.0f;
                if (!FR2_Asset.cacheImage.TryGetValue(name, out content))
                {
                    if (t == null)
                    {
                        content = new GUIContent(name);
                    }
                    else
                    {
                        Texture text = EditorGUIUtility.ObjectContent(null, t).image;
                        if (text == null)
                        {
                            content = new GUIContent(name);
                        }
                        else
                        {
                            content = new GUIContent(text, name);
                        }
                    }


                    FR2_Asset.cacheImage.Add(name, content);
                }

                if (content.image == null)
                {
                    width = EditorStyles.label.CalcSize(content).x;
                }
                else
                {
                    width = 20;
                }

                re.x    -= width;
                re.width = width;

                GUI.Label(re, content);
                re.x -= margin;                 // margin;
            }


            // var nameW = EditorStyles.boldLabel.CalcSize(new GUIContent(assetName)).x;
        }
示例#4
0
 public virtual bool isSelected()
 {
     return(FR2_Selection.IsSelect(asset.guid));
 }
示例#5
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();
        }