internal override ValidationResult ValidateSetting(Type validationTest, AbstractPluginManager pluginManager) { ValidationResult result = base.ValidateSetting(validationTest, pluginManager); if (result.impact != ValidationResult.Level.OK) { return(result); } GameObject sun = GetFirstInstanceInScene(); #if WEATHER_MAKER_PRESENT if (sun.GetComponent <WeatherMakerCelestialObjectScript>() == null) { ResolutionCallback callback = new ResolutionCallback(ConfigureSunAsCelestialObject); result = GetErrorResult(TestName, pluginManager, "The sun does not have the celestial object component attached.", validationTest.Name); List <ResolutionCallback> callbacks = new List <ResolutionCallback>(); callbacks.Add(callback); result.Callbacks = callbacks; return(result); } #endif return(GetPassResult(TestName, pluginManager, validationTest.Name)); }
public void AddCallback(ResolutionCallback callback) { bool alreadyExists = Callbacks.Exists(item => item.Label == callback.Label); if (!alreadyExists) { Callbacks.Add(callback); } }
internal override bool PostFieldCustomValidations(AbstractPluginManager pluginManager) { bool isPass = base.PostFieldCustomValidations(pluginManager); if (UnityEngine.Terrain.activeTerrain) { AddOrUpdateAsPass("Terrain is required.", pluginManager, "There is a terrain in the scene."); } else { ResolutionCallback callback = new ResolutionCallback(new ProfileCallback(GenerateTerrain)); AddOrUpdateAsError("Terrain is required.", pluginManager, "There is no terrain in the scene.", callback); isPass = false; } return(isPass); }
internal override ValidationResult ValidateSetting(Type validationTest, AbstractPluginManager pluginManager) { ValidationResult result = null; if (Instance == null) { if (AddToScene) { result = GetErrorResult(TestName, pluginManager, SuggestedValue.name + " is required but doesn't currently exist in the scene", validationTest.Name); } else { result = GetWarningResult(TestName, pluginManager, SuggestedValue.name + " doesn't currently exist in the scene. It is not required, if you don't want it then click the ignore button.", validationTest.Name); } List <ResolutionCallback> callbacks = new List <ResolutionCallback>(); ResolutionCallback callback = new ResolutionCallback(InstantiatePrefab); callbacks.Add(callback); result.Callbacks = callbacks; return(result); } return(GetPassResult(TestName, pluginManager, validationTest.Name)); }
internal ValidationResult GetWarningResult(string testName, AbstractPluginManager pluginManager, string message, string reportingTest, ResolutionCallback callback = null) { ValidationResult result = GetResult(testName, pluginManager, message, reportingTest, callback); result.impact = ValidationResult.Level.Warning; return(result); }
internal void AddDefaultFixCallback(ValidationResult result) { ResolutionCallback callback = new ResolutionCallback(Fix, "Automatically Resolve"); result.AddCallback(callback); }
private ValidationResult GetResult(string testName, AbstractPluginManager pluginManager, string message, string reportingTest, ResolutionCallback callback = null) { ValidationResult result = ValidationCollection.GetOrCreate(SettingName + " - " + testName, pluginManager, reportingTest); result.Message = message; result.impact = ValidationResult.Level.Warning; result.Callbacks = new List <ResolutionCallback>(); if (callback != null) { result.AddCallback(callback); } else { AddDefaultFixCallback(result); } return(result); }
private ValidationResult GetResult(string testName, AbstractPluginManager pluginManager, string message, string reportingTest, ResolutionCallback callback = null) { ValidationResult result = ResultCollection.GetOrCreate(testName, pluginManager, reportingTest); result.Message = message; result.impact = ValidationResult.Level.Warning; result.RemoveCallbacks(); if (callback != null) { result.AddCallback(callback); } return(result); }
/// <summary> /// Set the testName conducted by this ValidationTest to an Error. /// </summary> /// <param name="testName">Human readable test name.</param> /// <param name="message">Human readable message describing the test status.</param> internal void AddOrUpdateAsError(string testName, AbstractPluginManager pluginManager, string message, ResolutionCallback callback = null) { string reportingTest = this.GetType().Name; ValidationResult result = GetResult(testName, pluginManager, message, reportingTest, callback); result.impact = ValidationResult.Level.Error; ResultCollection.AddOrUpdate(result, reportingTest); }