示例#1
0
        private void OnGUI()
        {
            if (_customStyle == null)
            {
                InitCustomStyle();
            }

            if (Fscenes.config == null)
            {
                Fconfig.DrawNoConfig <FscenesConfig>(Fscenes.configName);
                return;
            }

            Flayout.BeginChangeCheck();

            _scroll = Flayout.BeginScroll(_scroll);

            Flayout.Space();

            Flayout.BeginHorizontal();
            Flayout.Label("Scene:", Fstyle.boldLabelLeft, Flayout.Width(60f));
            var oldNewScenePath = EditorPrefs.GetString(_sceneNewScenePathKey);
            var newScenePath    = Flayout.TextField(oldNewScenePath, Fstyle.textFieldLeft);

            if (newScenePath != oldNewScenePath)
            {
                EditorPrefs.SetString(_sceneNewScenePathKey, newScenePath);
            }

            if (Flayout.Button("Add", Fstyle.buttonRight, Flayout.Width(30f)))
            {
                var exists = true;
                if (newScenePath.Contains("/"))
                {
                    try
                    {
                        Fscenes.OpenScene(newScenePath);
                    }
                    catch (Exception exception)
                    {
                        Debug.LogError(exception.Message);
                        exists = false;
                    }
                }

                if (exists)
                {
                    Fscenes.config.scenePaths.Add(newScenePath);
                    Fscenes.config.devOnly.Add(false);
                    EditorPrefs.SetBool(_sceneOpenedKey + newScenePath, false);
                    EditorPrefs.SetString(_sceneNewScenePathKey, "");
                    UnityEngine.GUI.FocusControl(null);
                }
            }
            Flayout.EndHorizontal();

            for (int i = 0; i < Fscenes.config.scenePaths.Count; i++)
            {
                try
                {
                    var scenePath      = Fscenes.config.scenePaths[i];
                    var sceneNameArr   = scenePath.Split('/');
                    var sceneName      = sceneNameArr[sceneNameArr.Length - 1];
                    var opened         = Fscenes.HasScene(scenePath);
                    var needToBeOpened = EditorPrefs.GetBool(_sceneOpenedKey + scenePath) != opened;
                    var isScene        = scenePath.Contains("/");

                    Flayout.BeginHorizontal();

                    if (Flayout.Button("↑", Fstyle.buttonLeft, Flayout.Width(15f)))
                    {
                        if (i - 1 >= 0)
                        {
                            var spath    = Fscenes.config.scenePaths[i - 1];
                            var sdevOnly = Fscenes.config.devOnly[i - 1];
                            Fscenes.config.scenePaths[i - 1] = Fscenes.config.scenePaths[i];
                            Fscenes.config.devOnly[i - 1]    = Fscenes.config.devOnly[i];

                            Fscenes.config.scenePaths[i] = spath;
                            Fscenes.config.devOnly[i]    = sdevOnly;

                            if (Fscenes.config.mainScene == i)
                            {
                                Fscenes.config.mainScene--;
                            }
                        }
                    }

                    if (Flayout.Button("↓", isScene ? Fstyle.buttonCenter : Fstyle.buttonRight, Flayout.Width(15f)))
                    {
                        if (i + 1 < Fscenes.config.scenePaths.Count)
                        {
                            var spath    = Fscenes.config.scenePaths[i + 1];
                            var sdevOnly = Fscenes.config.devOnly[i + 1];
                            Fscenes.config.scenePaths[i + 1] = Fscenes.config.scenePaths[i];
                            Fscenes.config.devOnly[i + 1]    = Fscenes.config.devOnly[i];

                            Fscenes.config.scenePaths[i] = spath;
                            Fscenes.config.devOnly[i]    = sdevOnly;

                            if (Fscenes.config.mainScene == i)
                            {
                                Fscenes.config.mainScene++;
                            }
                        }
                    }

                    if (isScene)
                    {
                        needToBeOpened = Flayout.Toggle(needToBeOpened, " " + sceneName, _customStyle);

                        if (!opened && needToBeOpened)
                        {
                            Fscenes.OpenScene(scenePath);
                        }
                        else if (opened && !needToBeOpened)
                        {
                            Fscenes.CloseScene(scenePath);
                        }

                        Fscenes.config.devOnly[i] = Flayout.Toggle(Fscenes.config.devOnly[i], "D", Fstyle.buttonCenter, Flayout.Width(20f));
                        var isMainScene = Flayout.Toggle(Fscenes.config.mainScene == i, "M", Fstyle.buttonCenter, Flayout.Width(20f));
                        if (isMainScene)
                        {
                            Fscenes.config.mainScene = i;
                        }
                    }
                    else
                    {
                        Flayout.Label(scenePath);
                    }

                    if (Flayout.Button("x", isScene ? Fstyle.buttonRight : Fstyle.button, Flayout.Width(20f)))
                    {
                        EditorPrefs.DeleteKey(_sceneOpenedKey + Fscenes.config.scenePaths[i]);
                        Fscenes.config.scenePaths.RemoveAt(i);
                        Fscenes.config.devOnly.RemoveAt(i);
                        if (Fscenes.config.mainScene == i)
                        {
                            if (i == 0)
                            {
                                Fscenes.config.mainScene++;
                            }
                            else
                            {
                                Fscenes.config.mainScene--;
                            }
                        }
                    }

                    Fscenes.RefreshMainScene();

                    Flayout.EndHorizontal();
                }
                catch (System.Exception e)
                {
                    EditorGUILayout.HelpBox(e.Message, MessageType.Error);
                }
            }

            Flayout.Space();

            Flayout.EndScroll();

            if (Flayout.EndChangeCheck())
            {
                EditorUtility.SetDirty(Fscenes.config);
            }
        }
示例#2
0
        private void OnGUI()
        {
            Flayout.BeginChangeCheck();

            scroll = Flayout.BeginScroll(scroll);

            Flayout.Space();

            if (Flayout.Button("Refresh"))
            {
                Fmarks.RefreshMarks();
            }

            selectedGameObject = Selection.activeGameObject;

            Flayout.BeginVerticalBox();
            {
                enableFoldout = Flayout.Foldout(enableFoldout, "Enable Marks");
                if (enableFoldout)
                {
                    Flayout.BeginHorizontal();
                    {
                        if (Flayout.Button("Enable All", Fstyle.buttonLeft))
                        {
                            Fmarks.EnableAll(Fmarks.enableMarks);
                        }

                        if (Flayout.Button("Disable All", Fstyle.buttonRight))
                        {
                            Fmarks.DisableAll(Fmarks.enableMarks);
                        }
                    }
                    Flayout.EndHorizontal();

                    if (selectedGameObject != null)
                    {
                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((selectedGameObject.transform.parent != null ? (selectedGameObject.transform.parent.parent != null ? "..." : "") + "/" + selectedGameObject.transform.parent.name + "/" : "/") + selectedGameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (selectedGameObject.GetComponent <FmarkEnable>() == null)
                            {
                                if (Flayout.Button("Mark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    var comp = selectedGameObject.AddComponent <FmarkEnable>();
                                    comp.lastState = selectedGameObject.activeSelf;
                                    comp.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
                                    var disableMark = selectedGameObject.GetComponent <FmarkDisable>();
                                    if (disableMark != null)
                                    {
                                        DestroyImmediate(disableMark);
                                    }
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Unmark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    DestroyImmediate(selectedGameObject.GetComponent <FmarkEnable>());
                                    Fmarks.RefreshMarks();
                                }
                            }
                        }
                        Flayout.EndHorizontal();
                    }

                    Flayout.Space();

                    for (int i = 0; i < Fmarks.enableMarks.Length; i++)
                    {
                        var mark = Fmarks.enableMarks[i];

                        if (mark == null)
                        {
                            continue;
                        }

                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((mark.transform.parent != null ? (mark.transform.parent.parent != null ? "..." : "") + "/" + mark.transform.parent.gameObject.name + "/" : "") + mark.gameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (mark.gameObject.activeSelf)
                            {
                                if (Flayout.Button("Disable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(false);
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Enable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(true);
                                    Fmarks.RefreshMarks();
                                }
                            }

                            if (Flayout.Button("Unmark", Fstyle.buttonRight, Flayout.Width(50f)))
                            {
                                mark.gameObject.SetActive(true);
                                DestroyImmediate(mark);
                                Fmarks.RefreshMarks();
                            }
                        }
                        Flayout.EndHorizontal();
                    }
                }
            }
            Flayout.Space();
            Flayout.EndVertical();

            Flayout.BeginVerticalBox();
            {
                disableFoldout = Flayout.Foldout(disableFoldout, "Disable Marks");
                if (disableFoldout)
                {
                    Flayout.BeginHorizontal();
                    {
                        if (Flayout.Button("Enable All", Fstyle.buttonLeft))
                        {
                            Fmarks.EnableAll(Fmarks.disableMarks);
                        }

                        if (Flayout.Button("Disable All", Fstyle.buttonRight))
                        {
                            Fmarks.DisableAll(Fmarks.disableMarks);
                        }
                    }
                    Flayout.EndHorizontal();

                    if (selectedGameObject != null)
                    {
                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((selectedGameObject.transform.parent != null ? (selectedGameObject.transform.parent.parent != null ? "..." : "") + "/" + selectedGameObject.transform.parent.name + "/" : "/") + selectedGameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (selectedGameObject.GetComponent <FmarkDisable>() == null)
                            {
                                if (Flayout.Button("Mark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    var comp = selectedGameObject.AddComponent <FmarkDisable>();
                                    comp.lastState = selectedGameObject.activeSelf;
                                    comp.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
                                    var enableMark = selectedGameObject.GetComponent <FmarkEnable>();
                                    if (enableMark != null)
                                    {
                                        DestroyImmediate(enableMark);
                                    }
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Unmark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    DestroyImmediate(selectedGameObject.GetComponent <FmarkDisable>());
                                    Fmarks.RefreshMarks();
                                }
                            }
                        }
                        Flayout.EndHorizontal();
                    }

                    Flayout.Space();

                    for (int i = 0; i < Fmarks.disableMarks.Length; i++)
                    {
                        var mark = Fmarks.disableMarks[i];

                        if (mark == null)
                        {
                            continue;
                        }

                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((mark.transform.parent != null ? (mark.transform.parent.parent != null ? "..." : "") + "/" + mark.transform.parent.gameObject.name + "/" : "/") + mark.gameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (mark.gameObject.activeSelf)
                            {
                                if (Flayout.Button("Disable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(false);
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Enable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(true);
                                    Fmarks.RefreshMarks();
                                }
                            }

                            if (Flayout.Button("Unmark", Fstyle.buttonRight, Flayout.Width(50f)))
                            {
                                mark.gameObject.SetActive(true);
                                DestroyImmediate(mark);
                                Fmarks.RefreshMarks();
                            }
                        }
                        Flayout.EndHorizontal();
                    }
                }
            }
            Flayout.Space();
            Flayout.EndVertical();

            Flayout.BeginVerticalBox();
            {
                developmentFoldout = Flayout.Foldout(developmentFoldout, "Development Marks");
                if (developmentFoldout)
                {
                    Flayout.BeginHorizontal();
                    {
                        if (Flayout.Button("Enable All", Fstyle.buttonLeft))
                        {
                            Fmarks.EnableAll(Fmarks.developmentMarks);
                        }

                        if (Flayout.Button("Disable All", Fstyle.buttonRight))
                        {
                            Fmarks.DisableAll(Fmarks.developmentMarks);
                        }
                    }
                    Flayout.EndHorizontal();

                    if (selectedGameObject != null)
                    {
                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((selectedGameObject.transform.parent != null ? (selectedGameObject.transform.parent.parent != null ? "..." : "") + "/" + selectedGameObject.transform.parent.name + "/" : "/") + selectedGameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (selectedGameObject.GetComponent <FmarkDevelopment>() == null)
                            {
                                if (Flayout.Button("Mark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    var comp = selectedGameObject.AddComponent <FmarkDevelopment>();
                                    comp.lastState = selectedGameObject.activeSelf;
                                    comp.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Unmark", Fstyle.button, Flayout.Width(50f)))
                                {
                                    DestroyImmediate(selectedGameObject.GetComponent <FmarkDevelopment>());
                                    Fmarks.RefreshMarks();
                                }
                            }
                        }
                        Flayout.EndHorizontal();
                    }

                    Flayout.Space();

                    for (int i = 0; i < Fmarks.developmentMarks.Length; i++)
                    {
                        var mark = Fmarks.developmentMarks[i];

                        if (mark == null)
                        {
                            continue;
                        }

                        Flayout.BeginHorizontal();
                        {
                            Flayout.Label((mark.transform.parent != null ? (mark.transform.parent.parent != null ? "..." : "") + "/" + mark.transform.parent.gameObject.name + "/" : "") + mark.gameObject.name, Fstyle.labelLeft, Flayout.Width(100f));
                            Flayout.FlexibleSpace();

                            if (mark.gameObject.activeSelf)
                            {
                                if (Flayout.Button("Disable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(false);
                                    Fmarks.RefreshMarks();
                                }
                            }
                            else
                            {
                                if (Flayout.Button("Enable", Fstyle.buttonLeft, Flayout.Width(50f)))
                                {
                                    mark.gameObject.SetActive(true);
                                    Fmarks.RefreshMarks();
                                }
                            }

                            if (Flayout.Button("Unmark", Fstyle.buttonRight, Flayout.Width(50f)))
                            {
                                mark.gameObject.SetActive(true);
                                DestroyImmediate(mark);
                                Fmarks.RefreshMarks();
                            }
                        }
                        Flayout.EndHorizontal();
                    }
                }
            }
            Flayout.Space();
            Flayout.EndVertical();

            Flayout.Space();

            Flayout.EndScroll();
        }