Example #1
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            State = ResState.Loading;

#if UNITY_EDITOR
            if (SimulateAssetBundleInEditor)
            {
            }
            else
#endif
            {
                var url    = QFrameworkSettingData.AssetBundleName2Url(mAssetName);
                var bundle = AssetBundle.LoadFromFile(url);

                mUnloadFlag = true;

                if (bundle == null)
                {
                    Log.E("Failed Load AssetBundle:" + mAssetName);
                    OnResLoadFaild();
                    return(false);
                }

                AssetBundle = bundle;
            }

            State = ResState.Ready;

            return(true);
        }
Example #2
0
        public override IEnumerator DoLoadAsync(System.Action finishCallback)
        {
            //开启的时候已经结束了
            if (RefCount <= 0)
            {
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

#if UNITY_EDITOR
            if (SimulateAssetBundleInEditor)
            {
                yield return(null);
            }
            else
#endif
            {
                var url  = QFrameworkSettingData.AssetBundleName2Url(mAssetName);
                var abcR = AssetBundle.LoadFromFileAsync(url);

                mAssetBundleCreateRequest = abcR;
                yield return(abcR);

                mAssetBundleCreateRequest = null;

                if (!abcR.isDone)
                {
                    Log.E("AssetBundleCreateRequest Not Done! Path:" + mAssetName);
                    OnResLoadFaild();
                    finishCallback();
                    yield break;
                }

                AssetBundle = abcR.assetBundle;
            }

            State = ResState.Ready;
            finishCallback();
        }