コード例 #1
0
        private static void OnPlayModeStateChanged(PlayModeStateChange change)
        {
            if (ValidationSettings.ValidateScenesBeforePlayMode && change == PlayModeStateChange.ExitingEditMode)
            {
                var  validator = new SceneValidator();
                bool hasErrors = false;

                for (int i = 0; i < EditorSceneManager.sceneCount; i++)
                {
                    var scene = EditorSceneManager.GetSceneAt(i);
                    if (scene.isLoaded)
                    {
                        var validationReport = validator.CreateValidationReport(scene);
                        validationReport.LogErrors();

                        if (validationReport.HasErrors)
                        {
                            hasErrors = true;
                        }
                    }
                }

                // Abort entering play mode.
                if (hasErrors)
                {
                    EditorApplication.isPlaying = false;

                    var sceneView = SceneView.lastActiveSceneView;
                    if (sceneView != null)
                    {
                        sceneView.ShowNotification(new UnityEngine.GUIContent("- Play Mode Validation Failed -\nSee the console window for details."), 3.0);
                    }
                }
            }
        }
コード例 #2
0
        private static ValidationReport RunValidation()
        {
            var   validator   = new SceneValidator();
            Scene activeScene = EditorSceneManager.GetActiveScene();

            return(validator.CreateValidationReport(activeScene));
        }
コード例 #3
0
        public static void ValidateOpenScenes()
        {
            SceneValidator validator = new SceneValidator();

            for (int i = 0; i < EditorSceneManager.sceneCount; i++)
            {
                Scene scene = EditorSceneManager.GetSceneAt(i);
                validator.CreateValidationReport(scene).LogErrors();
            }
        }
コード例 #4
0
 public void TearDown()
 {
     sceneValidator = null;
 }
コード例 #5
0
 public void Setup()
 {
     sceneValidator = new SceneValidator();
 }