public AssetsResource DirectDownLoad(DownLoadResInfo info)
        {
            AssetsResource  ar   = info.Assets;
            AssetBundleInfo mabi = null;
            AssetBundleInfo abi  = null;
            AssetBundle     ab   = null;

            if ((mabi = GameAssetsMgr.Instance.CheckAssetBundle(info.MainAbPath)) != null)
            {
                ar.MainAbi = mabi;
            }
            else
            {
                ab         = AssetBundle.LoadFromFile(info.MainAbPath);
                abi        = new AssetBundleInfo(info.MainAbPath, ab);
                ar.MainAbi = abi;
                GameAssetsMgr.Instance.AddAssetBundle(abi);
            }

            while (info.DependenceAbPath.Count > 0)
            {
                string path = info.DependenceAbPath.Dequeue();
                if ((abi = GameAssetsMgr.Instance.CheckAssetBundle(path)) != null)
                {
                    ar.DependenceAbi.Add(abi);
                    continue;
                }
                ab  = AssetBundle.LoadFromFile(info.MainAbPath);
                abi = new AssetBundleInfo(info.MainAbPath, ab);
                ar.DependenceAbi.Add(abi);
                GameAssetsMgr.Instance.AddAssetBundle(abi);
            }
            return(ar);
        }
Ejemplo n.º 2
0
        public bool AddAssetsResource(AssetsResource ar)
        {
            if (_originObjDic.ContainsValue(ar))
            {
                return(false);
            }

            _originObjDic.Add(ar.AssetPath, ar);
            return(true);
        }
Ejemplo n.º 3
0
        public bool RemoveAssetsResource(AssetsResource ar)
        {
            if (!_originObjDic.ContainsValue(ar))
            {
                return(false);
            }

            _originObjDic.Remove(ar.AssetPath);
            return(true);
        }
Ejemplo n.º 4
0
        public bool ReleaseObject(Object obj)
        {
            AssetsResource res = null;

            foreach (AssetsResource ar in _originObjDic.Values)
            {
                if (obj.Equals(ar.OriginObj))
                {
                    res = ar;
                    break;
                }
            }
            if (res != null)
            {
                res.Release();
            }

            return(res != null);
        }
        IEnumerator WWWDownLoad(int index)
        {
            bool hasError = false;

            while (true)
            {
                //				if(!_isMaxiSpeed && index > 0)
                //				{
                //					yield return null;
                //					continue;
                //				}
                if (_downLoadQueues[index].Count == 0)
                {
                    yield return(null);

                    continue;
                }

                hasError = false;
                DownLoadResInfo info = _downLoadQueues[index].Dequeue();
                AssetsResource  ar   = info.Assets;

                AssetBundleInfo mabi = null;
                if ((mabi = GameAssetsMgr.Instance.CheckAssetBundle(info.MainAbPath)) != null)
                {
                    ar.MainAbi = mabi;
                }
                else
                {
                    WWW www = new WWW(info.MainAbPath);
                    www.threadPriority = _isMaxiSpeed ? ThreadPriority.High : ThreadPriority.Low;
                    while (!www.isDone)
                    {
                        yield return(null);
                    }

                    if (!string.IsNullOrEmpty(www.error))
                    {
                        hasError = true;
                        LogManager.LogError(info.MainAbPath);
                    }
                    else
                    {
                        ar.MainAbi = new AssetBundleInfo(www.url, www.assetBundle);
                        GameAssetsMgr.Instance.AddAssetBundle(ar.MainAbi);
                    }
                    www.Dispose();
                }

                while (info.DependenceAbPath.Count > 0)
                {
                    string          path = info.DependenceAbPath.Dequeue();
                    AssetBundleInfo abi  = null;
                    if ((abi = GameAssetsMgr.Instance.CheckAssetBundle(path)) != null)
                    {
                        ar.DependenceAbi.Add(abi);
                        continue;
                    }
                    WWW www = new WWW(path);
                    www.threadPriority = _isMaxiSpeed ? ThreadPriority.High : ThreadPriority.Low;
                    while (!www.isDone)
                    {
                        yield return(null);
                    }

                    if (!string.IsNullOrEmpty(www.error))
                    {
                        LogManager.LogError(path);
                        www.Dispose();
                        hasError = true;
                        yield return(null);

                        continue;
                    }

                    abi = new AssetBundleInfo(www.url, www.assetBundle);
                    ar.DependenceAbi.Add(abi);
                    GameAssetsMgr.Instance.AddAssetBundle(abi);
                    www.Dispose();
                    yield return(null);
                }

                if (hasError)
                {
                    GameAssetsMgr.Instance.RemoveAssetsResource(ar);
                }
                if (info.onLoadComplete != null)
                {
                    info.onLoadComplete(hasError ? null : ar);
                }

                yield return(null);
            }
        }