protected override void Execute() { var db = GetBuilderOfType <BuildScriptFastMode>(m_settings); if (db == null) { UnityEngine.Debug.Log($"Unable to find {nameof(BuildScriptFastMode)} builder in settings assets. Using default Instance and Scene Providers."); } var locator = new AddressableAssetSettingsLocator(m_settings); m_addressables.AddResourceLocator(locator); m_addressables.AddResourceLocator(new DynamicResourceLocator(m_addressables)); m_addressables.ResourceManager.postProfilerEvents = ProjectConfigData.PostProfilerEvents; if (!m_addressables.ResourceManager.postProfilerEvents) { m_Diagnostics.Dispose(); m_Diagnostics = null; m_addressables.ResourceManager.ClearDiagnosticCallbacks(); } //NOTE: for some reason, the data builders can get lost from the settings asset during a domain reload - this only happens in tests and custom instance and scene providers are not needed m_addressables.InstanceProvider = db == null ? new InstanceProvider() : ObjectInitializationData.CreateSerializedInitializationData(db.instanceProviderType.Value).CreateInstance <IInstanceProvider>(); m_addressables.SceneProvider = db == null ? new SceneProvider() : ObjectInitializationData.CreateSerializedInitializationData(db.sceneProviderType.Value).CreateInstance <ISceneProvider>(); m_addressables.ResourceManager.ResourceProviders.Add(new AssetDatabaseProvider()); m_addressables.ResourceManager.ResourceProviders.Add(new TextDataProvider()); m_addressables.ResourceManager.ResourceProviders.Add(new JsonAssetProvider()); m_addressables.ResourceManager.ResourceProviders.Add(new LegacyResourcesProvider()); m_addressables.ResourceManager.ResourceProviders.Add(new AtlasSpriteProvider()); m_addressables.ResourceManager.ResourceProviders.Add(new ContentCatalogProvider(m_addressables.ResourceManager)); WebRequestQueue.SetMaxConcurrentRequests(m_settings.MaxConcurrentWebRequests); if (m_settings.InitializationObjects.Count == 0) { Complete(locator, true, null); } else { List <AsyncOperationHandle> initOperations = new List <AsyncOperationHandle>(); foreach (var io in m_settings.InitializationObjects) { if (io is IObjectInitializationDataProvider) { var ioData = (io as IObjectInitializationDataProvider).CreateObjectInitializationData(); var h = ioData.GetAsyncInitHandle(m_addressables.ResourceManager); initOperations.Add(h); } } groupOp = m_addressables.ResourceManager.CreateGenericGroupOperation(initOperations, true); groupOp.Completed += op => { bool success = op.Status == AsyncOperationStatus.Succeeded; Complete(locator, success, success ? "" : $"{op.DebugName}, status={op.Status}, result={op.Result} failed initialization."); m_addressables.Release(op); }; } }
protected override void Execute() { Addressables.LogFormat("Addressables - runtime data operation completed with status = {0}, result = {1}.", m_rtdOp.Status, m_rtdOp.Result); if (m_rtdOp.Result == null) { Addressables.LogWarningFormat("Addressables - Unable to load runtime data at location {0}.", m_rtdOp); Complete(Result, false, string.Format("Addressables - Unable to load runtime data at location {0}.", m_rtdOp)); return; } #if UNITY_2019_3_OR_NEWER Addressables.LogFormat("Initializing Addressables version {0}.", m_rtdOp.Result.AddressablesVersion); #endif var rtd = m_rtdOp.Result; m_Addressables.ResourceManager.postProfilerEvents = rtd.ProfileEvents; WebRequestQueue.SetMaxConcurrentRequests(rtd.MaxConcurrentWebRequests); m_Addressables.Release(m_rtdOp); if (rtd.CertificateHandlerType != null) { m_Addressables.ResourceManager.CertificateHandlerInstance = Activator.CreateInstance(rtd.CertificateHandlerType) as CertificateHandler; } #if UNITY_EDITOR if (UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString() != rtd.BuildTarget) { Addressables.LogErrorFormat("Addressables - runtime data was built with a different build target. Expected {0}, but data was built with {1}. Certain assets may not load correctly including shaders. You can rebuild player content via the Addressables window.", UnityEditor.EditorUserBuildSettings.activeBuildTarget, rtd.BuildTarget); } #endif if (!rtd.LogResourceManagerExceptions) { ResourceManager.ExceptionHandler = null; } if (!rtd.ProfileEvents) { m_Diagnostics.Dispose(); m_Diagnostics = null; m_Addressables.ResourceManager.ClearDiagnosticCallbacks(); } Addressables.Log("Addressables - loading initialization objects."); ContentCatalogProvider ccp = m_Addressables.ResourceManager.ResourceProviders .FirstOrDefault(rp => rp.GetType() == typeof(ContentCatalogProvider)) as ContentCatalogProvider; if (ccp != null) { ccp.DisableCatalogUpdateOnStart = rtd.DisableCatalogUpdateOnStartup; ccp.IsLocalCatalogInBundle = rtd.IsLocalCatalogInBundle; } var locMap = new ResourceLocationMap("CatalogLocator", rtd.CatalogLocations); m_Addressables.AddResourceLocator(locMap); IList <IResourceLocation> catalogs; if (!locMap.Locate(ResourceManagerRuntimeData.kCatalogAddress, typeof(ContentCatalogData), out catalogs)) { Addressables.LogWarningFormat( "Addressables - Unable to find any catalog locations in the runtime data."); m_Addressables.RemoveResourceLocator(locMap); Complete(Result, false, "Addressables - Unable to find any catalog locations in the runtime data."); } else { Addressables.LogFormat("Addressables - loading content catalogs, {0} found.", catalogs.Count); m_loadCatalogOp = LoadContentCatalogInternal(catalogs, 0, locMap); } }