public AsyncOperationHandle <List <string> > Start(List <AddressablesImpl.ResourceLocatorInfo> locatorInfos) { m_LocatorInfos = new List <AddressablesImpl.ResourceLocatorInfo>(locatorInfos.Count); m_LocalHashes = new List <string>(locatorInfos.Count); var locations = new List <IResourceLocation>(locatorInfos.Count); foreach (var rl in locatorInfos) { if (rl.CanUpdateContent) { locations.Add(rl.HashLocation); m_LocalHashes.Add(rl.LocalHash); m_LocatorInfos.Add(rl); } } ContentCatalogProvider ccp = m_Addressables.ResourceManager.ResourceProviders .FirstOrDefault(rp => rp.GetType() == typeof(ContentCatalogProvider)) as ContentCatalogProvider; if (ccp != null) { ccp.DisableCatalogUpdateOnStart = false; } m_DepOp = m_Addressables.ResourceManager.CreateGroupOperation <string>(locations); return(m_Addressables.ResourceManager.StartOperation(this, m_DepOp)); }
public AsyncOperationHandle <List <IResourceLocator> > Start(IEnumerable <string> catalogIds) { m_LocatorInfos = new List <AddressablesImpl.ResourceLocatorInfo>(); var locations = new List <IResourceLocation>(); foreach (var c in catalogIds) { var loc = m_Addressables.GetLocatorInfo(c); locations.Add(loc.CatalogLocation); m_LocatorInfos.Add(loc); } if (locations.Count == 0) { return(m_Addressables.ResourceManager.CreateCompletedOperation(default(List <IResourceLocator>), "Content update not available.")); } ContentCatalogProvider ccp = m_Addressables.ResourceManager.ResourceProviders .FirstOrDefault(rp => rp.GetType() == typeof(ContentCatalogProvider)) as ContentCatalogProvider; if (ccp != null) { ccp.DisableCatalogUpdateOnStart = false; } m_DepOp = m_Addressables.ResourceManager.CreateGroupOperation <object>(locations); return(m_Addressables.ResourceManager.StartOperation(this, m_DepOp)); }
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; } var rtd = m_rtdOp.Result; 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; } // DiagnosticEventCollector.ResourceManagerProfilerEventsEnabled = rtd.ProfileEvents; 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; } 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); LoadContentCatalogInternal(catalogs, 0, locMap); } }
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; } Addressables.LogFormat("Initializing Addressables version {0}.", m_rtdOp.Result.AddressablesVersion); var rtd = m_rtdOp.Result; m_Addressables.ResourceManager.postProfilerEvents = rtd.ProfileEvents; WebRequestQueue.SetMaxConcurrentRequests(rtd.MaxConcurrentWebRequests); m_Addressables.CatalogRequestsTimeout = rtd.CatalogRequestsTimeout; foreach (var catalogLocation in rtd.CatalogLocations) { if (catalogLocation.Data != null && catalogLocation.Data is ProviderLoadRequestOptions loadData) { loadData.WebRequestTimeout = rtd.CatalogRequestsTimeout; } } 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); IResourceLocation remoteHashLocation = null; if (catalogs[0].Dependencies.Count == 2 && rtd.DisableCatalogUpdateOnStartup) { remoteHashLocation = catalogs[0].Dependencies[(int)ContentCatalogProvider.DependencyHashIndex.Remote]; catalogs[0].Dependencies[(int)ContentCatalogProvider.DependencyHashIndex.Remote] = catalogs[0].Dependencies[(int)ContentCatalogProvider.DependencyHashIndex.Cache]; } m_loadCatalogOp = LoadContentCatalogInternal(catalogs, 0, locMap, remoteHashLocation); } }