Esempio n. 1
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            State = ResState.Loading;

#if UNITY_EDITOR
            if (SimulateAssetBundleInEditor)
            {
            }
            else
#endif
            {
                var url    = ResKitUtil.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);
        }
Esempio n. 2
0
        public string[] GetAllDependenciesByUrl(string url)
        {
            var abName = ResKitUtil.AssetBundleUrl2Name(url);

            for (var i = mActiveAssetDataGroup.Count - 1; i >= 0; --i)
            {
                string[] depends;
                if (!mActiveAssetDataGroup[i].GetAssetBundleDepends(abName, out depends))
                {
                    continue;
                }

                return(depends);
            }

            return(null);
        }
Esempio n. 3
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  = ResKitUtil.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();
        }
Esempio n. 4
0
 private static string GetPlatformName()
 {
     return(ResKitUtil.GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
 }