private IEnumerator doLoadAssetBundleAsyn(string assetBundleName, Action <LYAssetBundle> callback) { string[] dependencies = GetDependencies(assetBundleName); if (dependencies.Length > 0) { int index = 0; while (index < dependencies.Length) { LYAssetAsynLoader dependLoader = new LYAssetAsynLoader(dependencies[index]); dependLoader.LoadAsyn(); while (dependLoader.IsLoaded == false) { yield return(null); } index++; } } yield return(null); LYAssetAsynLoader loader = new LYAssetAsynLoader(assetBundleName); loader.LoadAsyn(); while (loader.IsLoaded == false) { yield return(null); } if (callback != null) { callback(LYAssetCache.GetBundleCache(assetBundleName)); } }
internal void Release() { this.m_referencedCount--; if (this.m_referencedCount == 0) { //卸载资源 this.assetBundle.Unload(true); LYAssetCache.FreeBundle(assetBundleName); } }
public LYAssetBundle LoadAssetBundle(string assetBundleName) { LYAssetBundle bundle = LYAssetCache.GetBundleCache(assetBundleName); if (bundle != null) { return(bundle); } LoadDependencies(assetBundleName); return(doLoadAssetBundle(assetBundleName)); }
public string[] GetDependencies(string assetBundleName) { // 获取依赖包裹 string[] dependencies = this.Manifest.GetAllDependencies(assetBundleName); if (dependencies.Length != 0) { // 记录并且加载所有的依赖包裹 LYAssetCache.SetDependCache(assetBundleName, dependencies); } return(dependencies); }
public void LoadAssetBundleAsyn(string assetBundleName, Action <LYAssetBundle> callback) { LYAssetBundle bundle = LYAssetCache.GetBundleCache(assetBundleName); if (bundle != null) { if (callback != null) { callback(bundle); } return; } StartCoroutine(doLoadAssetBundleAsyn(assetBundleName, callback)); }
private IEnumerator doAsynLoad() { var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(LYAssetManager.FolderPath, m_assertName)); yield return(bundleLoadRequest); AssetBundle bundle = bundleLoadRequest.assetBundle; if (bundle == null) { Debug.LogError("AssetBundleName file not exist:" + Path.Combine(LYAssetManager.FolderPath, m_assertName)); yield break; } Debug.Log("AssetBundleName loaded:" + Path.Combine(LYAssetManager.FolderPath, m_assertName)); LYAssetCache.SetBundleCache(m_assertName, new LYAssetBundle(bundle, m_assertName)); m_state = State.Loaded; }
public void LoadAsyn() { if (m_state != State.None) { return; } var bundle = LYAssetCache.GetBundleCache(m_assertName); if (bundle != null) { //保留一次 bundle.Retain(); m_state = State.Loaded; return; } m_state = State.Loading; LYAssetManager.Instance.StartCoroutine(doAsynLoad()); }
private LYAssetBundle doLoadAssetBundle(string assetBundleName) { LYAssetBundle ly_bundle = LYAssetCache.GetBundleCache(assetBundleName); if (ly_bundle != null) { //保留一次 ly_bundle.Retain(); return(ly_bundle); } AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(FolderPath, assetBundleName)); if (bundle == null) { Debug.LogError("AssetBundleName file not exist:" + Path.Combine(FolderPath, assetBundleName)); return(null); } ly_bundle = new LYAssetBundle(bundle, assetBundleName); LYAssetCache.SetBundleCache(assetBundleName, ly_bundle); return(ly_bundle); }