static bool InitializeLoaderInstance(AdaptivePerformancePackageInitializationBase packageInit) { bool ret = EditorUtilities.AssetDatabaseHasInstanceOfType(packageInit.LoaderTypeName); if (!ret) { var obj = EditorUtilities.CreateScriptableObjectInstance(packageInit.LoaderFullTypeName, EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultLoaderPath)); ret = (obj != null); } return(ret); }
static bool InitializeSettingsInstance(AdaptivePerformancePackageInitializationBase packageInit) { bool ret = EditorUtilities.AssetDatabaseHasInstanceOfType(packageInit.SettingsTypeName); if (!ret) { var obj = EditorUtilities.CreateScriptableObjectInstance(packageInit.SettingsFullTypeName, EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultSettingsPath)); ret = packageInit.PopulateSettingsOnInitialization(obj); } return(ret); }
static void InitPackage(AdaptivePerformancePackageInitializationBase packageInit) { if (!InitializeLoaderInstance(packageInit)) { Debug.LogWarning( String.Format("{0} Loader Initialization not completed. You will need to create an instance of the loader manually before you can use the intended Adaptive Performance Provider Package.", packageInit.PackageName)); } if (!InitializeSettingsInstance(packageInit)) { Debug.LogWarning( String.Format("{0} Settings Initialization not completed. You will need to create an instance of settings to customize options specific to this package.", packageInit.PackageName)); } }
internal static void BeginPackageInitialization() { EditorApplication.update -= BeginPackageInitialization; foreach (var t in TypeLoaderExtensions.GetAllTypesWithInterface <IAdaptivePerformancePackage>()) { if (t.IsInterface || t.FullName.Contains("Unity.AdaptivePerformance.TestPackage") || t.FullName.Contains("UnityEditor.AdaptivePerformance.Editor.Metadata.AdaptivePerformanceKnownPackages")) { continue; } IAdaptivePerformancePackage package = Activator.CreateInstance(t) as IAdaptivePerformancePackage; if (package == null) { Debug.LogError($"Unable to find an implementation for expected package type {t.FullName}."); continue; } InitPackage(package); } foreach (var t in TypeLoaderExtensions.GetAllTypesWithInterface <AdaptivePerformancePackageInitializationBase>()) { if (t.IsInterface) { continue; } AdaptivePerformancePackageInitializationBase packageInit = Activator.CreateInstance(t) as AdaptivePerformancePackageInitializationBase; if (packageInit == null) { Debug.LogError($"Unable to find an implementation for expected package type {t.FullName}."); continue; } InitPackage(packageInit); } if (AdaptivePerformanceSettingsManager.Instance != null) { AdaptivePerformanceSettingsManager.Instance.ResetUi = true; } }