Example #1
0
            internal AssetAccessor LoadAsset(string assetPath, bool isScene, LoadAssetCallbackSet callbackSet, object context)
            {
                if (string.IsNullOrEmpty(assetPath))
                {
                    throw new ArgumentException("Shouldn't be null or empty.", "assetPath");
                }

                if (!ReadWriteIndex.AssetInfos.TryGetValue(assetPath, out var assetInfo))
                {
                    throw new ArgumentException(Utility.Text.Format("Asset info for path '{0}' not found.", assetPath));
                }

                int resourceGroup = ReadWriteIndex.ResourceBasicInfos[assetInfo.ResourcePath].GroupId;

                if (m_Owner.ResourceUpdater.GetResourceGroupStatus(resourceGroup) != ResourceGroupStatus.UpToDate)
                {
                    throw new InvalidOperationException(Utility.Text.Format(
                                                            "Asset '{0}' cannot be used until resource group '{1}' is done updating.",
                                                            assetPath, resourceGroup));
                }

                if (!m_AssetCaches.TryGetValue(assetPath, out var assetCache))
                {
                    assetCache = AcquireAssetCache(assetPath, assetInfo, isScene);
                }

                var ret = m_AssetAccessorPool.Acquire();

                ret.Init(assetCache, callbackSet, context);
                return(ret);
            }
        /// <inheritdoc />
        public IAssetAccessor LoadSceneAsset(string sceneAssetPath, LoadAssetCallbackSet callbackSet, object context)
        {
            if (m_UpdateChecker.Status != UpdateCheckerStatus.Success)
            {
                throw new InvalidOperationException("Update checking not successfully done.");
            }

            return(m_Loader.LoadAsset(sceneAssetPath, true, callbackSet, context));
        }
        internal void Init(AssetCache assetCache, LoadAssetCallbackSet callbackSet, object context)
        {
            if (m_SerialId > 0)
            {
                throw new InvalidOperationException("Oops, I'm not reset.");
            }

            m_AssetCache = assetCache ?? throw new ArgumentNullException(nameof(assetCache), "Oops!");
            m_SerialId   = NextSerialId();

            m_AssetCache.IncreaseRetainCount();

            CallbackSet = callbackSet;
            Context     = context;
            m_AssetCache.AddAccessor(this);
        }