Esempio n. 1
0
        // ------------------------------------------------------------------------------------------
        // 从AssetBundle里加载资源
        private void LoadBundleAsset(LoaderGroup group, AssetBundleInfo info, string name, Type type,
                                     GroupLoadedCallback onLoaded,
                                     bool async = true, LoadPriority priority = LoadPriority.Normal)
        {
            if (info == null || string.IsNullOrEmpty(name))
            {
                if (onLoaded != null)
                {
                    onLoaded(group, null);
                }

                return;
            }

            if (!async)
            {
                // 同步,直接加载
                //Logger.Log(string.Format("-->LoadBundleAsset: {0}", name));

                Object asset = info.LoadAsset(name, type);
                if (onLoaded != null)
                {
                    onLoaded(group, asset);
                }
            }
            else
            {
                // 异步,创建一个加载器后加载
                BundleAssetLoadParam param = new BundleAssetLoadParam {
                    Bundle = info.Bundle,
                    Type   = type
                };

                m_task.AddLoadTask(group, Loader.LoaderType.BundleAsset, name, param, (group1, data1) => {
                    // 加载回调
                    if (onLoaded != null)
                    {
                        onLoaded(group1, data1);
                    }
                }, true, priority, true);
            }
        }
Esempio n. 2
0
        public override void Load()
        {
            base.Load();

            BundleAssetLoadParam param = Param as BundleAssetLoadParam;

            if (param == null || param.Bundle == null || param.Type == null || string.IsNullOrEmpty(Path))
            {
                OnLoaded(null);
                return;
            }

            if (IsAsync)
            {
                m_request = param.Bundle.LoadAssetAsync(Path, param.Type);
            }
            else
            {
                Object asset = param.Bundle.LoadAsset(Path, param.Type);
                OnLoaded(asset);
            }
        }