/// <summary>
 /// Draws the label indicating if the currently edited scene configuration is the currently active configuration.
 /// </summary>
 /// <seealso cref="SMSceneConfigurtion.activeConfiguration"/>
 protected void ConfigurationStatusGUI()
 {
     if (Invalid)
     {
         EditorGUILayout.BeginHorizontal(boxStyle);
         GUILayout.Label(string.Empty, warnIconStyle);
         GUILayout.Label("The configuration is invalid.");
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("Fix configuration"))
         {
             FixConfiguration();
         }
         EditorGUILayout.EndHorizontal();
     }
     EditorGUILayout.Space();
     if (Target.activeConfiguration)
     {
         GUILayout.Label("This configuration will be used by the game.");
     }
     else
     {
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("The configuration is currently not active.");
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("Activate"))
         {
             SMSceneConfigurationUtil.EnsureActiveConfiguration(Target, true);
             SyncBuildSettingsIfRequired();
         }
         EditorGUILayout.EndHorizontal();
     }
 }
Beispiel #2
0
    /// <summary>
    /// Fixes configuration issues such as multiple active configurations or removed scenes
    /// </summary>
    protected void FixConfiguration()
    {
        List <UnityEngine.Object> objects = new List <UnityEngine.Object>(SMSceneConfigurationUtil.FindConfigurations().ToArray());

        CUUndoUtility.RegisterUndo(objects.ToArray(), "Fixing configuration");
        UpdateGuid();

        FixInvalidScenes();

        if (fixActiveState)
        {
            SMSceneConfigurationUtil.EnsureActiveConfiguration(Target, false);
        }

        invalidScreens = null;
        invalidLevels  = null;
        fixActiveState = false;
        EditorUtility.SetDirty(Target);
    }
Beispiel #3
0
    public override void OnInspectorGUI()                        // 画 GUI
    {
        ProDraw();
        if (Target.activeConfiguration)
        {
            GUILayout.Label("游戏使用该配置".AddYellow());
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("游戏不是使用这个配置");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("使用该配置"))
            {
                SMSceneConfigurationUtil.EnsureActiveConfiguration(Target, true);
                SyncBuildSettingsIfRequired();
            }
            EditorGUILayout.EndHorizontal();
        }

        MyCreate.Box(() =>
        {
            sceneListHeight = CUResizableContainer.BeginVertical(sceneListHeight);
            sceneListData   = CUListControl.SelectionList(sceneListData, scenes, sceneRenderer);
            CUResizableContainer.EndVertical();

            bool isChooseScene = !sceneListData.Empty;
            GUI.enabled        = isChooseScene;                                   // 判断有没有点击场景
            int width          = Screen.width / 3 - 10;
            MyGUI.Heng(() =>
            {
                MyGUI.Button(isChooseScene ? "关卡".AddGreen() : "关卡", width, ChangeToLevel);
                MyGUI.Button(isChooseScene ? "场景".AddOrange() : "关卡", width, ChangeToScreen);
                MyGUI.Button("Ignore", width, ChangeToIgnore);
            });
            GUI.enabled = !sceneListData.Empty && IsScreen(scenes[sceneListData.First]);// 判断点击的场景是否标记 Screen
            MyGUI.Heng(() =>
            {
                MyGUI.Button("开始场景", width, ChangeToFirstScreen);
                MyGUI.Button("关卡完成后场景", width, ChangeToFirstScreenAfterLevel);
                GUI.enabled = sceneListData.Selection.Count == 1;
                MyGUI.Button("打开", width, () =>
                {
                    OpenScene(sceneListData);
                });
            });
        });
        MyGUI.AddSpace(4);
        GUI.enabled = true;
        MyCreate.Box(() =>
        {
            levelListHeight = CUResizableContainer.BeginVertical(levelListHeight);
            levelListData   = CUListControl.SelectionList(levelListData, Target.levels, levelRenderer, "关卡");
            CUResizableContainer.EndVertical();

            GUI.enabled = !levelListData.Empty;
            MyGUI.Heng(() =>
            {
                MyGUI.AddSpace();
                MyGUI.Button("First", MoveToFirst);
                MyGUI.Button("↑", MoveUp);
                MyGUI.Button("↓", MoveDown);
                MyGUI.Button("Last", MoveToLast);
            });
            GUI.enabled = true;
        });
    }
Beispiel #4
0
    public override void OnInspectorGUI()                        // 画 GUI
    {
        ProDraw();
        if (Target.activeConfiguration)
        {
            GUILayout.Label("游戏使用该配置".AddYellow());
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("游戏不是使用这个配置");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("使用该配置"))
            {
                SMSceneConfigurationUtil.EnsureActiveConfiguration(Target, true);
                SyncBuildSettingsIfRequired();
            }
            EditorGUILayout.EndHorizontal();
        }
        int workWidth = Screen.width / 3 - 34;
        WorkflowActionEnum targetWork = Target.actionAfterGroup;
        bool isLevel = targetWork == WorkflowActionEnum.LoadNextLevel;

        MyGUI.Heng(() =>
        {
            MyGUI.Text("组结束,加载:");
            MyGUI.Button(isLevel?"[下一关卡]".AddGreen(): "下一关卡".AddLightGreen(), workWidth, () =>
            {
                if (!isLevel)
                {
                    ChangeToWorkflowAction(WorkflowActionEnum.LoadNextLevel);
                }
            });
            MyGUI.AddSpace(2);
            MyGUI.Button(isLevel ? "标记场景".AddLightGreen() : "[标记场景]".AddGreen(), workWidth, () =>
            {
                if (isLevel)
                {
                    ChangeToWorkflowAction(WorkflowActionEnum.LoadScreen);
                }
            });
            MyGUI.AddSpace();
            GUI.enabled = sceneListData.Selection.Count == 1;
            MyGUI.Button("打开", workWidth - 25, () =>
            {
                OpenScene(sceneListData);
            });
            GUI.enabled = true;
        });


        MyCreate.Box(() =>
        {
            sceneListHeight = CUResizableContainer.BeginVertical(sceneListHeight);
            sceneListData   = CUListControl.SelectionList(sceneListData, scenes, sceneRenderer);
            CUResizableContainer.EndVertical();

            bool isChooseScene = !sceneListData.Empty;
            GUI.enabled        = isChooseScene;                                   // 判断有没有点击场景
            int width          = Screen.width / 3 - 10;

            MyGUI.Heng(() =>
            {
                MyGUI.Button(isChooseScene ? "关卡".AddGreen() : "关卡", width, ChangeToLevel);
                MyGUI.Button(isChooseScene ? "场景".AddOrange() : "关卡", width, ChangeToScreen);
                MyGUI.Button("Ignore", width, ChangeToIgnore);
            });
            GUI.enabled = !sceneListData.Empty && IsScreen(scenes[sceneListData.First]);// 判断点击的场景是否标记 Screen
            MyCreate.Heng(() =>
            {
                MyGUI.Button("开始场景", width, ChangeToFirstScreen);
                MyGUI.Button("关卡完成后场景", width, ChangeToFirstScreenAfterLevel);
                GUI.enabled = GUI.enabled && Target.actionAfterGroup == WorkflowActionEnum.LoadScreen;// 是否选择了标记场景
                MyGUI.Button("完成组后场景", width, ChangeToFirstScreenAfterGroup);
            });
        });

        MyGUI.AddSpace(4);
        GUI.enabled = true;

        MyCreate.Box(() =>
        {
            levelListHeight = CUResizableContainer.BeginVertical(levelListHeight);
            EditorGUILayout.BeginHorizontal();
            groupListWidth = CUResizableContainer.BeginHorizontal(groupListWidth);
            int lastGroup  = groupListData.First;
            groupListData  = CUListControl.SelectionList(groupListData, Target.groups, groupRenderer, "组");
            if (lastGroup != groupListData.First)
            {
                levelListData.ClearSelection();
            }

            CUResizableContainer.EndHorizontal();
            GUI.enabled   = SelectedGroup != null;
            levelListData = CUListControl.SelectionList(levelListData, currentGroupLevels, levelRenderer, "关卡");
            GUI.enabled   = true;
            EditorGUILayout.EndHorizontal();
            CUResizableContainer.EndVertical();

            MyGUI.Heng(() =>
            {
                MyGUI.Button("+", AddGroup);
                GUI.enabled = !groupListData.Empty && Target.groups.Length > 1;
                MyGUI.Button("-", RemoveGroup);
                GUI.enabled = !groupListData.Empty;
                MyGUI.Button("改名", RenameGroup);
                GUI.enabled = true;
                MyGUI.AddSpace();
                GUI.enabled = !levelListData.Empty;
                MyGUI.Button("First", MoveToFirst);
                MyGUI.Button("↑", MoveUp);
                MyGUI.Button("↓", MoveDown);
                MyGUI.Button("Last", MoveToLast);
                GUI.enabled = true;
            });
        });
    }