Пример #1
0
        /// <summary>
        ///     Draws the scene entry
        /// </summary>
        private void DrawSceneEntry(SceneField scene)
        {
            EditorGUILayout.ObjectField(scene.SceneAsset, typeof(SceneAsset), true);

            if (SOFlowEditorUtilities.DrawColourButton("Load", SOFlowEditorSettings.AcceptContextColour))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Additive);
            }

            if (SOFlowEditorUtilities.DrawColourButton("Replace", Color.yellow))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Single);
            }

            if (SOFlowEditorUtilities.DrawColourButton("Unload", SOFlowEditorSettings.DeclineContextColour))
            {
                EditorSceneManager
                .CloseScene(SceneManager.GetSceneByPath(AssetDatabase.GetAssetPath(scene.SceneAsset)), true);
            }
        }
Пример #2
0
        /// <summary>
        ///     Draws the footer panel
        /// </summary>
        private void DrawFooterPanel()
        {
            if (SOFlowEditorUtilities.DrawColourButton("Load Scene Set", SOFlowEditorSettings.AcceptContextColour))
            {
                int loadMode = EditorUtility.DisplayDialogComplex("Load Scene Set", "Select load mode.", "Full",
                                                                  "Additive (Keep Current Scenes", "Cancel");

                if (loadMode == 0)
                {
                    _sceneSets[_selectedSceneSet - 1].LoadSceneSet(false);
                }
                else if (loadMode == 1)
                {
                    _sceneSets[_selectedSceneSet - 1].LoadSceneSet(true);
                }
            }

            if (SOFlowEditorUtilities.DrawColourButton("Unload Scene Set", SOFlowEditorSettings.DeclineContextColour))
            {
                _sceneSets[_selectedSceneSet - 1].UnloadSceneSet();
            }
        }
Пример #3
0
        /// <summary>
        ///     Draws the load scene set button.
        /// </summary>
        private void DrawLoadSceneSetButton()
        {
            if (SOFlowEditorUtilities.DrawColourButton("Load Scene Set"))
            {
                if (EditorUtility.DisplayDialog("Load Scene Set",
                                                "Replacing currently opens scenes with Scene Set.\nAre you sure?",
                                                "Load", "Cancel"))
                {
                    _target.LoadSceneSet(false);
                }
            }

            if (SOFlowEditorUtilities.DrawColourButton("Load Scene Set (Keep Current Scenes)"))
            {
                _target.LoadSceneSet(true);
            }

            if (SOFlowEditorUtilities.DrawColourButton("Unload Scene Set"))
            {
                _target.UnloadSceneSet();
            }
        }
Пример #4
0
        /// <summary>
        ///     Draws evaluation testing tools.
        /// </summary>
        private void DrawEvaluationTest()
        {
            Color originalGUIColor = GUI.backgroundColor;

            SOFlowEditorUtilities.DrawColourLayer(_testResult
                                                  ? SOFlowEditorSettings.AcceptContextColour
                                                  : SOFlowEditorSettings.DeclineContextColour,
                                                  () =>
            {
                if (SOFlowEditorUtilities.DrawColourButton("Test Comparison"))
                {
                    _testResult = _target.Evaluate();
                }

                GUI.backgroundColor =
                    _testResult
                                                          ? SOFlowEditorSettings.AcceptContextColour
                                                          : SOFlowEditorSettings.DeclineContextColour;

                GUILayout.Label(_testResult.ToString(), SOFlowStyles.BoldCenterLabel);
            });

            GUI.backgroundColor = originalGUIColor;
        }
Пример #5
0
        /// <summary>
        ///     Draws the header panel.
        /// </summary>
        private void DrawHeaderPanel()
        {
            List <GUIContent> sceneSetContent = new List <GUIContent>();

            sceneSetContent.Add(new GUIContent("None"));

            foreach (SceneSet set in _sceneSets)
            {
                sceneSetContent.Add(new GUIContent(set.name));
            }

            _selectedSceneSet = EditorGUILayout.Popup(_selectedSceneSet, sceneSetContent.ToArray());

            List <GUIContent> sceneContent = new List <GUIContent>();

            sceneContent.Add(new GUIContent("Load Any Scene"));

            foreach (SceneAsset scene in _scenes)
            {
                sceneContent.Add(new GUIContent(scene.name));
            }

            int selectedScene = EditorGUILayout.Popup(0, sceneContent.ToArray());

            if (selectedScene > 0)
            {
                int loadMode = EditorUtility.DisplayDialogComplex("Load Scene", "Select load mode.", "Full",
                                                                  "Additive (Keep Current Scenes", "Cancel");

                if (loadMode == 0)
                {
                    EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(_scenes[selectedScene - 1]),
                                                 OpenSceneMode.Single);
                }
                else if (loadMode == 1)
                {
                    EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(_scenes[selectedScene - 1]),
                                                 OpenSceneMode.Additive);
                }
            }

            if (SOFlowEditorUtilities.DrawColourButton("Refresh", Color.cyan))
            {
                _sceneSets.Clear();
                _scenes.Clear();

                string[] assetFiles = Directory.GetFiles(Application.dataPath, "*.asset", SearchOption.AllDirectories);
                string[] sceneFiles = Directory.GetFiles(Application.dataPath, "*.unity", SearchOption.AllDirectories);

                foreach (string file in assetFiles)
                {
                    try
                    {
                        SceneSet set =
                            AssetDatabase.LoadAssetAtPath <SceneSet>(file.Replace($"{Application.dataPath}\\",
                                                                                  "Assets/"));

                        if (set != null)
                        {
                            _sceneSets.Add(set);
                        }
                    }
                    catch
                    {
                        // Ignore
                    }
                }

                foreach (string file in sceneFiles)
                {
                    try
                    {
                        SceneAsset scene =
                            AssetDatabase.LoadAssetAtPath <SceneAsset>(file.Replace($"{Application.dataPath}\\",
                                                                                    "Assets/"));

                        if (scene != null)
                        {
                            _scenes.Add(scene);
                        }
                    }
                    catch
                    {
                        // Ignore
                    }
                }

                _sceneSets.Sort((firstScene, secondScene) => firstScene.name.CompareTo(secondScene.name));
                _scenes.Sort((firstScene, secondScene) => firstScene.name.CompareTo(secondScene.name));
            }
        }
Пример #6
0
        /// <summary>
        ///     Draws the event stack.
        /// </summary>
        private void DrawEventStack()
        {
            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Event Stack", SOFlowStyles.BoldCenterLabel);
            GUILayout.FlexibleSpace();

            EditorGUILayout.LabelField($"Size: {_target.EventStack.Count}", SOFlowStyles.WordWrappedMiniLabel);

            EditorGUILayout.EndHorizontal();

            SOFlowEditorUtilities.DrawScrollViewColourLayer(SOFlowEditorSettings.TertiaryLayerColour, ref _logScrollPosition,
                                                            () =>
            {
                foreach (GameEventLog log in _target.EventStack)
                {
                    SOFlowEditorUtilities.DrawSecondaryLayer(() =>
                    {
                        for (int i = 0,
                             errorIndex
                                 = 0,
                             condition
                                 = log
                                   .Listener
                                   .Count;
                             i <
                             condition;
                             i++)
                        {
                            SOFlowEditorUtilities
                            .DrawHorizontalColourLayer(log.IsError[i] ? SOFlowEditorSettings.DeclineContextColour : SOFlowEditorSettings.SecondaryLayerColour,
                                                       () =>
                            {
                                EditorGUILayout
                                .LabelField($"[{log.LogTime:T}] {log.Listener[i].GetObjectType().Name}");

                                EditorGUILayout
                                .ObjectField(log
                                             .Listener
                                             [i]
                                             .GetGameObject(),
                                             typeof
                                             (GameObject
                                             ),
                                             true);

                                if
                                (log
                                 .IsError
                                 [i]
                                )
                                {
                                    if
                                    (SOFlowEditorUtilities
                                     .DrawColourButton("Log",
                                                       SOFlowEditorSettings
                                                       .TertiaryLayerColour)
                                    )
                                    {
                                        _currentErrorMessage
                                            = $"{log.ErrorMessages[errorIndex]}\n\n{log.StackTraces[errorIndex]}";

                                        _currentErrorData
                                            = log
                                              .ErrorData
                                              [errorIndex];
                                    }
                                }
                            });

                            if (log
                                .IsError
                                [i]
                                )
                            {
                                errorIndex
                                ++;
                            }
                        }
                    });
                }
            }, GUILayout.MaxHeight(_scrollHeight));
        }