static AutomatedQARuntimeSettings() { #if UNITY_EDITOR if (!Directory.Exists(Path.Combine(Application.dataPath, AutomatedQASettingsResourcesPath))) { Directory.CreateDirectory(Path.Combine(Application.dataPath, AutomatedQASettingsResourcesPath)); } #endif // Handle required configs. Re-add them if deleted from config settings file. List <AutomationSet> setsToReAddToConfigSettingsFile = new List <AutomationSet>(); string settingKey = Keys.RecordingFolderName; AutomationSet set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, RecordingFolderName); setsToReAddToConfigSettingsFile.Add(set); } RecordingFolderName = set.Value.ToString(); settingKey = Keys.ActivatePlaybackVisualFx; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, ActivatePlaybackVisualFx.ToString()); setsToReAddToConfigSettingsFile.Add(set); } ActivatePlaybackVisualFx = bool.Parse(set.Value.ToString()); settingKey = Keys.ActivateClickFeedbackFx; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, ActivateClickFeedbackFx.ToString()); setsToReAddToConfigSettingsFile.Add(set); } ActivateClickFeedbackFx = bool.Parse(set.Value.ToString()); settingKey = Keys.ActivateDragFeedbackFx; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, ActivateDragFeedbackFx.ToString()); setsToReAddToConfigSettingsFile.Add(set); } ActivateDragFeedbackFx = bool.Parse(set.Value.ToString()); settingKey = Keys.ActivateHighlightFeedbackFx; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, ActivateHighlightFeedbackFx.ToString()); setsToReAddToConfigSettingsFile.Add(set); } ActivateHighlightFeedbackFx = bool.Parse(set.Value.ToString()); settingKey = Keys.EnableScreenshots; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, EnableScreenshots.ToString()); setsToReAddToConfigSettingsFile.Add(set); } EnableScreenshots = bool.Parse(set.Value.ToString()); settingKey = Keys.PostActionScreenshotDelay; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, PostActionScreenshotDelay.ToString()); setsToReAddToConfigSettingsFile.Add(set); } PostActionScreenshotDelay = float.Parse(set.Value.ToString()); settingKey = Keys.UseDynamicWaits; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, UseDynamicWaits.ToString()); setsToReAddToConfigSettingsFile.Add(set); } UseDynamicWaits = bool.Parse(set.Value.ToString()); settingKey = Keys.DynamicWaitTimeout; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, DynamicWaitTimeout.ToString()); setsToReAddToConfigSettingsFile.Add(set); } DynamicWaitTimeout = float.Parse(set.Value.ToString()); settingKey = Keys.DynamicLoadSceneTimeout; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, DynamicLoadSceneTimeout.ToString()); setsToReAddToConfigSettingsFile.Add(set); } DynamicLoadSceneTimeout = float.Parse(set.Value.ToString()); settingKey = Keys.LogLevel; set = settings.Configs.Find(c => c.Key == settingKey); if (set == null || set == default(AutomationSet)) { set = new AutomationSet(settingKey, ((int)LogLevel).ToString()); setsToReAddToConfigSettingsFile.Add(set); } LogLevel = Enum.TryParse <AQALogger.LogLevel>(set.Value.ToString(), out AQALogger.LogLevel i) ? i : AQALogger.LogLevel.Info; #if UNITY_EDITOR // Add back any required configs that were deleted by the user. if (setsToReAddToConfigSettingsFile.Any()) { AutomatedQASettingsData newConfig = new AutomatedQASettingsData(); newConfig.Configs.AddRange(setsToReAddToConfigSettingsFile); newConfig.Configs.AddRange(settings.Configs); File.WriteAllText(Path.Combine(Application.dataPath, AutomatedQASettingsResourcesPath, AutomatedQaSettingsFileName), JsonUtility.ToJson(newConfig)); } #endif }
public static AutomatedQASettingsData GetCustomSettingsData() { if (configTextAsset == null) { AutomatedQASettingsData configCategories = new AutomatedQASettingsData(); configCategories.Configs.Add(new AutomationSet(Keys.LogLevel, LogLevel.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.EnableScreenshots, EnableScreenshots.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.PostActionScreenshotDelay, PostActionScreenshotDelay.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.RecordingFolderName, RecordingFolderName)); configCategories.Configs.Add(new AutomationSet(Keys.ActivatePlaybackVisualFx, ActivatePlaybackVisualFx.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.ActivateClickFeedbackFx, ActivateClickFeedbackFx.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.ActivateDragFeedbackFx, ActivateDragFeedbackFx.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.ActivateHighlightFeedbackFx, ActivateHighlightFeedbackFx.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.UseDynamicWaits, UseDynamicWaits.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.DynamicWaitTimeout, DynamicWaitTimeout.ToString())); configCategories.Configs.Add(new AutomationSet(Keys.DynamicLoadSceneTimeout, DynamicLoadSceneTimeout.ToString())); #if UNITY_EDITOR File.WriteAllText(Path.Combine(Application.dataPath, AutomatedQASettingsResourcesPath, AutomatedQaSettingsFileName), JsonUtility.ToJson(configCategories)); #endif return(configCategories); } return(JsonUtility.FromJson <AutomatedQASettingsData>(configTextAsset.text)); }