Beispiel #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);
            }
        }
Beispiel #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);
        }