예제 #1
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);
        }