internal void LoadCatalog(string idToLoad, bool isLocalCatalogInBundle, bool isLocalCatalog)
 {
     try
     {
         if (isLocalCatalogInBundle && isLocalCatalog)
         {
             var bc = new BundledCatalog(idToLoad);
             bc.OnLoaded += ccd =>
             {
                 m_ContentCatalogData = ccd;
                 OnCatalogLoaded(ccd);
             };
             bc.LoadCatalogFromBundleAsync();
         }
         else
         {
             IResourceLocation location = new ResourceLocationBase(idToLoad, idToLoad,
                                                                   typeof(JsonAssetProvider).FullName, EnumLocalResourceMode.Disable, typeof(ContentCatalogData));
             m_ProviderInterface.ResourceManager.ProvideResource <ContentCatalogData>(location).Completed +=
                 op =>
             {
                 m_ContentCatalogData = op.Result;
                 m_ProviderInterface.ResourceManager.Release(op);
                 OnCatalogLoaded(m_ContentCatalogData);
             };
         }
     }
     catch (Exception ex)
     {
         m_ProviderInterface.Complete <ContentCatalogData>(null, false, ex);
     }
 }
            internal void LoadCatalog(string idToLoad, bool isLocalCatalogInBundle, bool isLocalCatalog)
            {
                try
                {
                    if (isLocalCatalogInBundle && isLocalCatalog)
                    {
                        m_BundledCatalog           = new BundledCatalog(idToLoad);
                        m_BundledCatalog.OnLoaded += ccd =>
                        {
                            m_ContentCatalogData = ccd;
                            OnCatalogLoaded(ccd);
                        };
                        m_BundledCatalog.LoadCatalogFromBundleAsync();
                    }
                    else
                    {
                        ResourceLocationBase location = new ResourceLocationBase(idToLoad, idToLoad,
                                                                                 typeof(JsonAssetProvider).FullName, typeof(ContentCatalogData));
                        if (m_ProviderInterface.Location.Data is ProviderLoadRequestOptions providerData)
                        {
                            location.Data = providerData.Copy();
                        }

                        m_ContentCatalogDataLoadOp            = m_ProviderInterface.ResourceManager.ProvideResource <ContentCatalogData>(location);
                        m_ContentCatalogDataLoadOp.Completed += CatalogLoadOpCompleteCallback;
                    }
                }
                catch (Exception ex)
                {
                    m_ProviderInterface.Complete <ContentCatalogData>(null, false, ex);
                }
            }
            public void Start(ProvideHandle providerInterface, bool disableCatalogUpdateOnStart, bool isLocalCatalogInBundle)
            {
                m_ProviderInterface = providerInterface;
                m_LocalDataPath     = null;
                m_RemoteHashValue   = null;

                List <object> deps = new List <object>(); // TODO: garbage. need to pass actual count and reuse the list

                m_ProviderInterface.GetDependencies(deps);
                string idToLoad = DetermineIdToLoad(m_ProviderInterface.Location, deps, disableCatalogUpdateOnStart);

                Addressables.LogFormat("Addressables - Using content catalog from {0}.", idToLoad);

                bool isLocalCatalog = idToLoad.Equals(GetTransformedInternalId(m_ProviderInterface.Location));

                if (isLocalCatalogInBundle && isLocalCatalog)
                {
                    try
                    {
                        var bc = new BundledCatalog(idToLoad);
                        bc.OnLoaded += ccd =>
                        {
                            m_ContentCatalogData = ccd;
                            OnCatalogLoaded(ccd);
                        };
                        bc.LoadCatalogFromBundleAsync();
                    }
                    catch (Exception ex)
                    {
                        m_ProviderInterface.Complete <ContentCatalogData>(null, false, ex);
                    }
                }
                else
                {
                    IResourceLocation location = new ResourceLocationBase(idToLoad, idToLoad, typeof(JsonAssetProvider).FullName, typeof(ContentCatalogData));
                    providerInterface.ResourceManager.ProvideResource <ContentCatalogData>(location).Completed += op =>
                    {
                        m_ContentCatalogData = op.Result;
                        m_ProviderInterface.ResourceManager.Release(op);
                        OnCatalogLoaded(m_ContentCatalogData);
                    };
                }
            }
Beispiel #4
0
            internal void LoadCatalog(string idToLoad, bool loadCatalogFromLocalBundle)
            {
                try
                {
                    ProviderLoadRequestOptions providerLoadRequestOptions = null;
                    if (m_ProviderInterface.Location.Data is ProviderLoadRequestOptions providerData)
                    {
                        providerLoadRequestOptions = providerData.Copy();
                    }

                    if (loadCatalogFromLocalBundle)
                    {
                        int webRequestTimeout = providerLoadRequestOptions?.WebRequestTimeout ?? 0;
                        m_BundledCatalog           = new BundledCatalog(idToLoad, webRequestTimeout);
                        m_BundledCatalog.OnLoaded += ccd =>
                        {
                            m_ContentCatalogData = ccd;
                            OnCatalogLoaded(ccd);
                        };
                        m_BundledCatalog.LoadCatalogFromBundleAsync();
                    }
                    else
                    {
                        ResourceLocationBase location = new ResourceLocationBase(idToLoad, idToLoad,
                                                                                 typeof(JsonAssetProvider).FullName, typeof(ContentCatalogData));
                        location.Data = providerLoadRequestOptions;

                        m_ContentCatalogDataLoadOp            = m_ProviderInterface.ResourceManager.ProvideResource <ContentCatalogData>(location);
                        m_ContentCatalogDataLoadOp.Completed += CatalogLoadOpCompleteCallback;
                    }
                }
                catch (Exception ex)
                {
                    m_ProviderInterface.Complete <ContentCatalogData>(null, false, ex);
                }
            }