//同步加载函数 //fullPath: DebugSrc的下一级路径,例如路径: Assets/StreamingAssets/DebugSrc/Prefab/aaa 即路径: Prefab/aaa public UnityEngine.Object SynLoadSrc(ESrcType typeSrc, string fullPath, Type typeObj) { if (Global.Instance.useAssetBundle == false) { try { UnityEngine.Object obj = Resources.Load(fullPath, typeObj); if (obj != null) return Instantiate(obj); return null; } catch (Exception ex) { Debug.LogException(ex); } } //加载bundle中的文件不需要路径 string filename = System.IO.Path.GetFileName(fullPath); string bundlename = Enum.GetName(typeof(ESrcType), typeSrc); if (AssetBundleDic.ContainsKey(bundlename)) { UnityEngine.Object obj = AssetBundleDic[bundlename].Load(filename, typeObj); if (obj != null) return Instantiate(obj); else return null; } return null; }
public bool IsloadAssetbundleComplete(ESrcType type) { string bundlename = Enum.GetName(typeof(ESrcType), type); if (AssetBundleDic.ContainsKey(bundlename)) return true; return false; }
public void UnloadAssetbundle(ESrcType type,bool releseInstanse) { string bundlename = Enum.GetName(typeof(ESrcType), type); if (AssetBundleDic.ContainsKey(bundlename)) { AssetBundleDic[bundlename].Unload(releseInstanse); AssetBundleDic.Remove(bundlename); } }
public void LoadAssetbundle(ESrcType type) { string bundlename = Enum.GetName(typeof(ESrcType), type); if (Global.Instance.resUpdate == null || AssetBundleDic.ContainsKey(bundlename)) { return; } StartCoroutine(Global.Instance.resUpdate.LoadBundle(bundlename + ".assetbundle", delegate(WWW w) { AssetBundleDic.Add(bundlename, w.assetBundle); })); }