示例#1
0
        private void Update()
        {
            if (_runner == null)
            {
                return;
            }
            if (!_runner.IsRunning())
            {
                return;
            }

            _runner.ContinueRunning();

            ForceEditorWindowUpdate();

            if (!_runner.IsComplete())
            {
                return;
            }

            if (AssetValidatorUtility.IsDebugging)
            {
                Debug.Log("AssetValidatorRunner has completed...");
            }

            CacheLogs();
            ForceEditorWindowUpdate();

            if (AssetValidatorUtility.EditorOuputFormat != OutputFormat.None)
            {
                using (var writer = new AssetValidatorLogWriter(AssetValidatorUtility.EditorFilename,
                                                                AssetValidatorUtility.EditorOuputFormat))
                {
                    var logs = _logger.GetLogs();

                    if (AssetValidatorUtility.EditorOuputFormat == OutputFormat.Html)
                    {
                        writer.CreateHtmlStyles(logs);
                    }

                    writer.AppendHeader();
                    for (var i = 0; i < logs.Count; i++)
                    {
                        writer.AppendVLog(logs[i]);
                    }

                    writer.AppendFooter();
                    writer.Flush();
                }
            }
        }
示例#2
0
        public static Result RunValidation(SceneValidationMode vMode,
                                           OutputFormat oFormat,
                                           bool doValidateProjectAssets = false,
                                           bool doValidateAcrossScenes  = false,
                                           string fileName = "asset_validator_results")
        {
            AssetValidatorUtility.EditorOuputFormat = oFormat;
            AssetValidatorUtility.EditorFilename    = fileName;

            try
            {
                var assetLogger = new AssetValidatorLogger();
                using (var assetValidationRunner = new AssetValidatorRunner(assetLogger, vMode))
                {
                    if (doValidateProjectAssets)
                    {
                        assetValidationRunner.EnableProjectAssetValidation();
                    }

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

                    assetValidationRunner.Run();
                }

                var logs = assetLogger.GetLogs();
                if (AssetValidatorUtility.EditorOuputFormat != OutputFormat.None)
                {
                    using (var writer = new AssetValidatorLogWriter(AssetValidatorUtility.EditorFilename,
                                                                    AssetValidatorUtility.EditorOuputFormat))
                    {
                        if (AssetValidatorUtility.EditorOuputFormat == OutputFormat.Html)
                        {
                            writer.CreateHtmlStyles(logs);
                        }

                        writer.AppendHeader();
                        for (var i = 0; i < logs.Count; i++)
                        {
                            writer.AppendVLog(logs[i]);
                        }

                        writer.AppendFooter();
                        writer.Flush();
                    }
                }

                var result = new Result {
                    isSuccessful = logs.Any(x => x.vLogType == VLogType.Error)
                };
                result.message = result.isSuccessful
                    ? "No AssetValidation errors were found."
                    : "Several AssetValidation errors were found";

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result()
                {
                    isSuccessful = false,
                    message = string.Format("AssetValidation failed to be run with the following exception: [{0}]", ex)
                });
            }
        }