/// <summary>
        /// Runs validation against the project in <see cref="SceneValidationMode"/>
        /// <paramref name="validationMode"/> and writes the log file to a file with a custom name.
        /// </summary>
        /// <param name="validationMode">The <see cref="SceneValidationMode"/> the validation is run in.</param>
        /// <param name="fileOutputFormat">The <see cref="FileOutputFormat"/> the file will be written in, if any.</param>
        /// <param name="doValidateProjectAssets">True if project assets should be validated, false if not.</param>
        /// <param name="doValidateAcrossScenes">True if cross-scene validation should be performed.</param>
        /// <param name="fileName">A custom filename for the log results to be written to.</param>
        /// <returns></returns>
        public static Result RunValidation(
            SceneValidationMode validationMode,
            FileOutputFormat fileOutputFormat,
            bool doValidateProjectAssets,
            bool doValidateAcrossScenes,
            string fileName)
        {
            try
            {
                var logCache = new LogCache();
                var assetValidationRunner = new AssetValidatorRunner(logCache, validationMode);
                if (doValidateProjectAssets)
                {
                    assetValidationRunner.EnableProjectAssetValidation();
                }

                if (doValidateAcrossScenes)
                {
                    assetValidationRunner.EnableCrossSceneValidation();
                }

                assetValidationRunner.Run();

                var newFileName = string.IsNullOrEmpty(fileName)
                                        ? EditorConstants.DefaultLogFilename
                                        : fileName;

                LogFileWriter.WriteLogs(newFileName, fileOutputFormat, logCache);

                var result = new Result
                {
                    isSuccessful = logCache.All(x => x.logType != LogType.Error)
                };
                result.message = result.isSuccessful
                                        ? ValidationSuccessMessage
                                        : ValidationFailedMessage;

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result
                {
                    isSuccessful = false,
                    message = string.Format(ValidationErrorFormat, ex)
                });
            }
        }
        private void OnValidateSelectionClick(
            SceneValidationMode validationMode,
            bool doValidateProjectAssets = false,
            bool doValidateAcrossScenes  = false)
        {
            // Only perform validation across multiple scenes if the current scene is saved, or
            // barring that if you don't care if it gets unloaded and lose changes
            var canExecute   = true;
            var currentScene = SceneManager.GetActiveScene();

            if (currentScene.isDirty &&
                validationMode != SceneValidationMode.None &&
                validationMode != SceneValidationMode.ActiveScene)
            {
                var didSave = EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() && !currentScene.isDirty;
                if (!didSave)
                {
                    canExecute = EditorUtility.DisplayDialog(
                        EditorConstants.EditorWindowTitle,
                        EditorConstants.ContinuePromptMessage,
                        EditorConstants.ProceedValidationButtonText,
                        EditorConstants.CancelButtonText);
                }
            }

            if (!canExecute)
            {
                return;
            }

            // Clear out any remaining logs and queue up an AssetValidationRunner with
            // the desired config
            _logCache.ClearLogs();
            _runner = new AssetValidatorRunner(_logCache, validationMode);

            if (doValidateProjectAssets)
            {
                _runner.EnableProjectAssetValidation();
            }

            if (doValidateAcrossScenes)
            {
                _runner.EnableCrossSceneValidation();
            }
        }