Пример #1
0
        public bool Draw()
        {
            if (dirty)
            {
                RefreshView(cacheAssetList);
            }


            if (fc.nChunks2 > 0 && fc.nScaned < fc.nChunks2)
            {
                FR2_Cache api = FR2_Cache.Api;
                float     w   = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 70f;
                api.priority = EditorGUILayout.IntSlider("Priority", api.priority, 0, 5);
                EditorGUIUtility.labelWidth = w;

                Rect  rect = GUILayoutUtility.GetRect(1, Screen.width, 18f, 18f);
                float p    = fc.nScaned / (float)fc.nChunks2;

                EditorGUI.ProgressBar(rect, p, string.Format("Scanning {0} / {1}", fc.nScaned, fc.nChunks2));
                GUILayout.FlexibleSpace();
                return(true);
            }

            DrawHeader();
            groupDrawer.Draw();
            return(false);
        }
Пример #2
0
        protected bool DrawEnable()
        {
            FR2_Cache api = FR2_Cache.Api;

            if (api == null)
            {
                return(false);
            }

            bool v = api.disabled;

            if (v)
            {
                EditorGUILayout.HelpBox("Find References 2 is disabled!", MessageType.Warning);
                if (GUILayout.Button("Enable"))
                {
                    api.disabled = !api.disabled;
                    Repaint();
                }

                return(!api.disabled);
            }

            if (!api.ready)
            {
                float w = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 70f;
                api.priority = EditorGUILayout.IntSlider("Priority", api.priority, 0, 5);
                EditorGUIUtility.labelWidth = w;
            }

            return(!api.disabled);
        }
Пример #3
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
        }
Пример #4
0
        internal static void CreateCache()
        {
            _cache = CreateInstance <FR2_Cache>();
            AssetDatabase.CreateAsset(_cache, DEFAULT_CACHE_PATH);
            EditorUtility.SetDirty(_cache);
            AssetDatabase.SaveAssets();

            FoundCache(true, true);
            _cache.Check4Changes(!EditorApplication.isPlaying, true);
        }
Пример #5
0
        private void OnEnable()
        {
#if FR2_DEBUG
            Debug.Log("OnEnabled : " + _cache);
#endif
            if (_cache == null)
            {
                _cache = this;
            }
            Check4Changes(!EditorApplication.isPlaying, false);
        }
Пример #6
0
 private static bool RestoreCacheFromPath(string path, bool savePrefs, bool writeFile)
 {
     if (string.IsNullOrEmpty(path))
     {
         return(false);
     }
     _cache = FR2_Unity.LoadAssetAtPath <FR2_Cache>(path);
     if (_cache != null)
     {
         FoundCache(savePrefs, writeFile);
     }
     return(_cache != null);
 }
Пример #7
0
 private static List <Object> GetSelectionDependencies()
 {
     if (!FR2_Cache.isReady)
     {
         Debug.LogWarning("FR2 cache not yet ready, please open Window > FR2_Window !");
         return(null);
     }
     return(FR2_Cache.FindUsage(FR2_Unity.Selection_AssetGUIDs).Select(
                guid =>
     {
         var assetPath = AssetDatabase.GUIDToAssetPath(guid);
         return FR2_Unity.LoadAssetAtPath <Object>(assetPath);
     }
                ).ToList());
 }
Пример #8
0
        protected bool CheckDrawHeader()
        {
            if (EditorApplication.isCompiling)
            {
                EditorGUILayout.HelpBox("Compiling scripts, please wait!", MessageType.Warning);
                Repaint();
                return(false);
            }

            if (EditorApplication.isUpdating)
            {
                EditorGUILayout.HelpBox("Importing assets, please wait!", MessageType.Warning);
                Repaint();
                return(false);
            }

            InitIfNeeded();

            if (EditorSettings.serializationMode != SerializationMode.ForceText)
            {
                EditorGUILayout.HelpBox("FR2 requires serialization mode set to FORCE TEXT!", MessageType.Warning);
                if (GUILayout.Button("FORCE TEXT"))
                {
                    EditorSettings.serializationMode = SerializationMode.ForceText;
                }

                return(false);
            }

            if (FR2_Cache.hasCache && !FR2_Cache.CheckSameVersion())
            {
                EditorGUILayout.HelpBox("Incompatible cache version found, need a full refresh may take time!",
                                        MessageType.Warning);
                if (GUILayout.Button("Scan project"))
                {
                    FR2_Cache.DeleteCache();
                    FR2_Cache.CreateCache();
                }

                return(false);
            }

            if (!FR2_Cache.isReady)
            {
                if (!FR2_Cache.hasCache)
                {
                    EditorGUILayout.HelpBox(
                        "FR2 cache not found!\nFirst scan may takes quite some time to finish but you would be able to work normally while the scan works in background...",
                        MessageType.Warning);
                    if (GUILayout.Button("Scan project"))
                    {
                        FR2_Cache.CreateCache();
                    }

                    return(false);
                }

                if (!DrawEnable())
                {
                    return(false);
                }

                FR2_Cache api  = FR2_Cache.Api;
                string    text = "Refreshing ... " + (int)(api.progress * api.workCount) + " / " + api.workCount;
                Rect      rect = GUILayoutUtility.GetRect(1f, Screen.width, 18f, 18f);
                EditorGUI.ProgressBar(rect, api.progress, text);
                Repaint();
                return(false);
            }


            if (!DrawEnable())
            {
                return(false);
            }

            willRepaint = Event.current.type == EventType.ScrollWheel;
            int newTab = selectedTab;

            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);

                GUIContent icon = Icon.icons.Lock;
                if (lockSelection)
                {
                    icon = Icon.icons.LockOn;
                }

                bool v = GUILayout.Toggle(lockSelection, icon, EditorStyles.toolbarButton, GUILayout.Width(21f));

                GUI.contentColor = color;

                if (v != lockSelection)
                {
                    lockSelection = v;
                    if (lockSelection == false)
                    {
                        OnSelectionChange();
                    }

                    willRepaint = true;
                }


                for (var i = 0; i < TOOLBARS.Length; i++)
                {
                    if (ShowScene && i > 1)
                    {
                        break;
                    }

                    bool isSelected = selectedTab == i;
                    bool b          = GUILayout.Toggle(isSelected, TOOLBARS[i], EditorStyles.toolbarButton);
                    if (b != isSelected)
                    {
                        newTab = i;
                    }
                }

                // newTab = GUILayout.Toolbar(selectedTab, TOOLBARS);
            }
            GUILayout.EndHorizontal();

            if (newTab != selectedTab)
            {
                selectedTab = newTab;
                OnTabChanged();
                // Check4Changes means delay calls to OnReady :: Refresh !
                //if (FR2_Cache.Api.isReady) FR2_Cache.Api.Check4Changes();
                OnReady();
            }

            if (Selected == null)
            {
                Selected = new List <FR2_Asset>();
            }

            return(true);
        }
Пример #9
0
        private void OnGUI()
        {
            if (window == null)
            {
                Initialize();
            }

            if (EditorSettings.serializationMode != SerializationMode.ForceText)
            {
                EditorGUILayout.HelpBox("FR2 requires serialization mode set to FORCE TEXT!", MessageType.Warning);
                if (GUILayout.Button("FORCE TEXT"))
                {
                    EditorSettings.serializationMode = SerializationMode.ForceText;
                }

                return;
            }

            if (!FR2_Cache.isReady)
            {
                if (!FR2_Cache.hasCache)
                {
                    EditorGUILayout.HelpBox("FR2 cache not found!\nFirst scan may takes quite some time to finish but you would be able to work normally while the scan works in background...", MessageType.Warning);
                    if (GUILayout.Button("Scan project"))
                    {
                        FR2_Cache.CreateCache();
                    }

                    return;
                }

                if (!DrawEnable())
                {
                    return;
                }

                var api  = FR2_Cache.Api;
                var text = "Refreshing ... " + (int)(api.progress * api.workCount) + " / " + api.workCount;
                var rect = GUILayoutUtility.GetRect(1f, Screen.width, 18f, 18f);
                EditorGUI.ProgressBar(rect, api.progress, text);
                Repaint();
                return;
            }

            if (!DrawEnable())
            {
                return;
            }

            var newTab = GUILayout.Toolbar(selectedTab, TOOLBARS);

            if (newTab != selectedTab)
            {
                selectedTab = newTab;
                // Check4Changes means delay calls to OnReady :: Refresh !
                //if (FR2_Cache.Api.isReady) FR2_Cache.Api.Check4Changes();
                OnReady();
            }

            var willRepaint = Event.current.type == EventType.ScrollWheel;

            if (Selected == null)
            {
                Selected = new List <FR2_Asset>();
            }

            //if (Selected.Count == 0){
            //	GUILayout.Label("Nothing selected");
            //}

            if (IsFocusingUses)
            {
                //Uses.Draw();
                UsesDrawer.Draw();
            }
            else if (IsFocusingUsedBy)
            {
                //UsedBy.Draw();
                UsedByDrawer.Draw();
            }
            else if (IsFocusingDuplicate)
            {
                willRepaint = Duplicated.Draw() | willRepaint;
            }
            else if (IsFocusingUnused)
            {
                DrawUnused();
            }
            else if (IsFocusingGUIDs)
            {
                DrawGUIDs();
            }

            if (willRepaint)
            {
                Repaint();
            }
        }