Beispiel #1
0
        public static IRes Create(string name, short assetType)
        {
            switch (assetType)
            {
            case eResType.kAssetBundle:
                return(AssetBundleRes.Allocate(name));

            case eResType.kABAsset:
                return(AssetRes.Allocate(name));

            case eResType.kABScene:
                return(SceneRes.Allocate(name));

            case eResType.kInternal:
                return(InternalRes.Allocate(name));

            case eResType.kNetImageRes:
                return(NetImageRes.Allocate(name));

            case eResType.kHotUpdateRes:
                return(HotUpdateRes.Allocate(name));

            default:
                Log.e("Invalid assetType :" + assetType);
                return(null);
            }
        }
Beispiel #2
0
        public static AssetBundleRes Allocate(string name)
        {
            AssetBundleRes res = ObjectPool <AssetBundleRes> .S.Allocate();

            if (res != null)
            {
                res.name = name;
                res.InitAssetBundleName();
            }
            return(res);
        }
Beispiel #3
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)
            {
                Log.e("Failed to Load Asset, Not Find AssetBundleImage:" + assetBundleName);
                return(false);
            }

            resState = eResState.kLoading;

            //TimeDebugger timer = ResMgr.S.timeDebugger;

            //timer.Begin("LoadSync Asset:" + m_Name);

            HoldDependRes();

            UnityEngine.Object obj = abR.assetBundle.LoadAsset(m_Name);
            //timer.End();

            UnHoldDependRes();

            if (obj == null)
            {
                Log.e("Failed Load Asset:" + m_Name);
                OnResLoadFaild();
                return(false);
            }

            m_Asset = obj;

            resState = eResState.kReady;
            //Log.i(string.Format("Load AssetBundle Success.ID:{0}, Name:{1}", m_Asset.GetInstanceID(), m_Name));

            //timer.Dump(-1);
            return(true);
        }
Beispiel #4
0
            public IRes CreateRes(string name)
            {
                AssetData data = AssetDataTable.S.GetAssetData(name);

                switch (data.assetType)
                {
                case eResType.kAssetBundle:
                    return(AssetBundleRes.Allocate(name));

                case eResType.kABAsset:
                    return(AssetRes.Allocate(name));

                case eResType.kABScene:
                    return(SceneRes.Allocate(name));

                default:
                    return(null);
                }
            }
Beispiel #5
0
        public void OnSyncLoadFinish(IResLoader loader, AssetBundleRes res)
        {
            //Log.w("OnSyncLoadFinish:AssetBundleRes:" + res.name);
            if (res.assetBundle == null)
            {
                return;
            }

            string[] assetNames = res.assetBundle.GetAllAssetNames();

            if (assetNames == null)
            {
                return;
            }

            for (int i = assetNames.Length - 1; i >= 0; --i)
            {
                loader.Add2Load(PathHelper.FullAssetPath2Name(assetNames[i]), null, false);
            }
        }
Beispiel #6
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)
            {
                Log.e("Failed to Load Asset, Not Find AssetBundleImage:" + abR);
                return(false);
            }


            resState = eResState.kReady;
            return(true);
        }
Beispiel #7
0
 public void OnSyncLoadFinish(IResLoader loader, AssetBundleRes res)
 {
 }
Beispiel #8
0
 public virtual void OnAsyncLoadFinish(IResLoader loader, AssetBundleRes res)
 {
 }
Beispiel #9
0
        public override IEnumerator StartIEnumeratorTask(Action finishCallback)
        {
            if (refCount <= 0)
            {
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

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

            if (abR == null || abR.assetBundle == null)
            {
                Log.e("Failed to Load Asset, Not Find AssetBundleImage:" + assetBundleName);
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

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

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

            m_AssetBundleRequest = abQ;

            yield return(abQ);

            m_AssetBundleRequest = null;

            UnHoldDependRes();

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

            if (!abQ.isDone)
            {
                Log.e("Failed Load Asset:" + m_Name);
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

            m_Asset = abQ.asset;

            if (m_Asset == null)
            {
                Log.e("Failed Load Asset:" + m_Name);
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

            resState = eResState.kReady;

            finishCallback();
        }