Exemple #1
0
        void UnloadResourceByInfo(UUIInfo _info)
        {
            if (_info is UUIInfoAssetBundle)
            {
                UUIInfoAssetBundle info = _info as UUIInfoAssetBundle;

                UAssetBundleLoaderProxyManager proxyManager = Manager.AssetBundleManager[info.GetLoaderName()];;

                if (proxyManager == null)
                {
                    return;
                }

                UAssetBundleLoaderProxy proxy;
                if (string.IsNullOrEmpty(info.ProxyName))
                {
                    proxy = proxyManager.GetDefaultProxy();
                }
                else
                {
                    proxy = proxyManager.GetProxy(info.ProxyName);
                }

                proxy?.GetLoader(info.PackageName).UnloadAsset(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 从AssetBundle中加载UI
        /// </summary>
        /// <param name="_info">UI的信息</param>
        /// <param name="_callback">完成后的回调函数</param>
        /// <returns></returns>
        UUIWorker LoadFromAssetBundle(UUIInfoAssetBundle _info, EWorkerState _nextState, Action <UUIWorker, GameObject> _callback)
        {
            UAssetBundleLoaderProxyManager proxyManager = Manager.AssetBundleManager[_info.GetLoaderName()];;

            if (proxyManager == null)
            {
                Output.Error("从AssetBundle加载{0}.{1}UI失败,加载器{2}不存在.", _info.PackageName, _info.AssetName, _info.GetLoaderName());
                return(null);
            }

            UAssetBundleLoaderProxy proxy;

            if (string.IsNullOrEmpty(_info.ProxyName))
            {
                proxy = proxyManager.GetDefaultProxy();
            }
            else
            {
                proxy = proxyManager.GetProxy(_info.ProxyName);
            }

            if (proxy == null)
            {
                Output.Error("从AssetBundle加载{0}.{1}UI失败,没有有效的加载器代理组件{2}.", _info.PackageName, _info.AssetName, _info.ProxyName);
                return(null);
            }

            var request = proxy.GetLoader(_info.PackageName).LoadAssetAsync <GameObject>(_info.AssetName);

            UUIWorker worker = new UUIWorker(EWorkerState.Loading, _nextState, _info, _info.IsSceneObject);

            AddedToContainer(worker, _nextState);
            worker.Request = new UUIRequestBy(request, worker, _callback);
            return(worker);
        }
Exemple #3
0
 public void AddProxyManager(string _name, UAssetBundleLoaderProxyManager _manager)
 {
     if (_name == NAME_PATH || _name == NAME_RES || _manager == null)
     {
         return;
     }
     ProxyManagers[_name] = _manager;
 }
Exemple #4
0
 internal UAssetBundleManager(UAssetBundlePool _instance)
 {
     Pool            = _instance;
     ManifestManager = new UAssetBundleManifestManager();
     AsyncLoader     = new UAssetBundleAsyncLoader(this, Pool, ManifestManager);
     PathLoader      = new UAssetBundleLoaderProxyManager(new UAssetBundleLoaderFromPathAdapter(AsyncLoader));
     ResLoader       = new UAssetBundleLoaderProxyManager(new UAssetBundleLoaderFromResourceAdapter(AsyncLoader));
     ProxyManagers.Add(NAME_PATH, PathLoader);
     ProxyManagers.Add(NAME_RES, ResLoader);
 }