/// <summary>
        /// 加载资源对象
        /// </summary>
        /// <param name="assetName">资源名称</param>
        /// <param name="assetType">资源类型</param>
        /// <param name="param">附加参数</param>
        /// <returns></returns>
        public AssetOperationHandle LoadAssetAsync(string assetName, System.Type assetType, IAssetParam param)
        {
            IAssetProvider provider = TryGetProvider(assetName);

            if (provider == null)
            {
                if (assetType == typeof(SceneInstance))
                {
                    IsSceneLoader = true;
                    SceneInstanceParam sceneParam = param as SceneInstanceParam;
                    provider = new AssetSceneProvider(this, assetName, assetType, sceneParam);
                }
                else if (assetType == typeof(PackageInstance))
                {
                    throw new NotImplementedException(nameof(PackageInstance));
                }
                else
                {
                    if (this is AssetBundleLoader)
                    {
                        provider = new AssetBundleProvider(this, assetName, assetType);
                    }
                    else if (this is AssetDatabaseLoader)
                    {
                        provider = new AssetDatabaseProvider(this, assetName, assetType);
                    }
                    else
                    {
                        throw new NotImplementedException($"{this.GetType()}");
                    }
                }
                _providers.Add(provider);
            }
            return(provider.Handle);
        }
Exemple #2
0
        /// <summary>
        /// 异步加载场景
        /// </summary>
        /// <param name="sceneName">场景名称</param>
        public AssetOperationHandle LoadSceneAsync(string sceneName, SceneInstanceParam instanceParam)
        {
            IAssetProvider provider = TryGetProvider(sceneName);

            if (provider == null)
            {
                IsSceneLoader = true;
                provider      = new AssetSceneProvider(this, sceneName, instanceParam);
                _providers.Add(provider);
            }

            // 引用计数增加
            provider.Reference();
            return(provider.Handle);
        }