示例#1
0
        public override IEnumerator StartIEnumeratorTask(Action finishCallback)
        {
            if (refCount <= 0)
            {
                OnResLoadFailed();
                finishCallback();
                yield break;
            }

            AssetBundleRes abR = ResMgr.S.GetRes <AssetBundleRes>(assetBundleName);

            if (abR == null || abR.assetBundle == null)
            {
                OnResLoadFailed();
                finishCallback();
                yield break;
            }

            //确保加载过程中依赖资源不被释放:目前只有AssetRes需要处理该情况
            HoldDependRes();

            AssetBundleRequest abQ = abR.assetBundle.LoadAssetAsync(AssetName);

            m_AssetBundleRequest = abQ;

            yield return(abQ);

            m_AssetBundleRequest = null;

            UnHoldDependRes();

            if (refCount <= 0)
            {
                OnResLoadFailed();
                finishCallback();
                yield break;
            }

            if (!abQ.isDone)
            {
                OnResLoadFailed();
                finishCallback();
                yield break;
            }

            m_Asset = abQ.asset;

            if (m_Asset == null)
            {
                OnResLoadFailed();
                finishCallback();
                yield break;
            }

            State = ResState.Ready;

            finishCallback();
        }
示例#2
0
        public static AssetBundleRes Allocate(string name)
        {
            AssetBundleRes res = ObjectPool <AssetBundleRes> .S.Allocate();

            if (res != null)
            {
                res.AssetName = name;
                res.InitAssetBundleName();
            }
            return(res);
        }
示例#3
0
            public IRes CreateRes(string name)
            {
                AssetData data = AssetDataTable.S.GetAssetData(name);

                switch (data.AssetType)
                {
                case ResLoadType.AssetBundle:
                    return(AssetBundleRes.Allocate(name));

                case ResLoadType.ABAsset:
                    return(AssetRes.Allocate(name));

                case ResLoadType.ABScene:
                    return(SceneRes.Allocate(name));

                default:
                    return(null);
                }
            }
示例#4
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(assetBundleName))
            {
                return(false);
            }

            AssetBundleRes abR = ResMgr.S.GetRes <AssetBundleRes>(assetBundleName);

            if (abR == null || abR.assetBundle == null)
            {
                return(false);
            }

            State = ResState.Ready;
            return(true);
        }
示例#5
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(assetBundleName))
            {
                return(false);
            }

            AssetBundleRes abR = ResMgr.S.GetRes <AssetBundleRes>(assetBundleName);

            if (abR == null || abR.assetBundle == null)
            {
                return(false);
            }

            State = ResState.Loading;

            HoldDependRes();

            UnityEngine.Object obj = abR.assetBundle.LoadAsset(AssetName);
            UnHoldDependRes();

            if (obj == null)
            {
                OnResLoadFailed();
                return(false);
            }

            m_Asset = obj;

            State = ResState.Ready;
            return(true);
        }