public static IEnumerator CreateAsync(string name) { if (string.IsNullOrEmpty(name))//空场景 { GameObject obj = new GameObject("AssetScene"); if (Application.isPlaying) { GameObject.DontDestroyOnLoad(obj); } AssetScene assetScene = obj.AddComponent <AssetScene>(); m_current = assetScene; yield return(null); } else { GameObject obj = new GameObject("AssetScene");//需要加载资源 if (Application.isPlaying) { GameObject.DontDestroyOnLoad(obj); } AssetScene assetScene = obj.AddComponent <AssetScene>(); assetScene.assetBundleName = GetAssetBundleNameOfScene(name); yield return(ABsManager.LoadAsync(assetScene.assetBundleName)); m_current = assetScene; } }
public static AssetScene Create(string name) { if (string.IsNullOrEmpty(name))//空场景 { GameObject obj = new GameObject("AssetScene"); if (Application.isPlaying) { GameObject.DontDestroyOnLoad(obj); } return(obj.AddComponent <AssetScene>()); } else { GameObject obj = new GameObject("AssetScene");//需要加载资源 if (Application.isPlaying) { GameObject.DontDestroyOnLoad(obj); } AssetScene assetScene = obj.AddComponent <AssetScene>(); assetScene.assetBundleName = GetAssetBundleNameOfScene(name); Debug.Log("Load scene from AB " + assetScene.assetBundleName); ABsManager.Load(assetScene.assetBundleName); return(assetScene); } }
public void UnloadAsset(string path) { path = path.Replace("\\", "/"); path = string.Format(basePath, path.Replace("\\", "/")); string assetBundleName = AssetBundleAssetRecord.GetAssetBundleName(path); ABsManager.Unload(assetBundleName); }
public static void RemovePre() { if (m_pre) { if (!string.IsNullOrEmpty(m_pre.assetBundleName)) { ABsManager.Unload(m_pre.assetBundleName); } GameObject.Destroy(m_pre.gameObject); } }
public void Init(Pattern pattern = Pattern.Resources) { this.m_pattern = pattern; if (inited == false) { inited = true; Debug.Log("资源加载方式:" + m_pattern); if (pattern == Pattern.AssetBundle) { ABsManager abs = ABsManager.Instance; } } }
public AsyncABLoader(string path) { orgPath = path; path = string.Format("assets/resources/{0}", path.Replace("\\", "/")); this.path = path; assetBundleName = AssetBundleAssetRecord.GetAssetBundleName(path); if (assetBundleName != null && assetBundleName != "") { this.assetBundleName = assetBundleName.ToLower(); AssetScene.Current.StartCoroutine(ABsManager.LoadAsync(assetBundleName)); } }
public void Clear() { for (int i = 0; i < list.Count; i++) { if (!isDontDestroyOnload(list[i])) { ABsManager.Unload(list[i].assetbundleName); } else { lastSceneRemains.Add(list[i]); } } }
void LateUpdate() { if (Time.time - time > 0f) { time = Time.time + 1f; for (int i = 0; i < list.Count; i++) { CheckInf(list[i]); if (list[i].refCount == 0) { ABsManager.Unload(list[i].assetbundleName); list.RemoveAt(i); } } } }
public Object LoadAsset(string path) { Object obj = null; path = string.Format(basePath, path.Replace("\\", "/")); string assetBundleName = AssetBundleAssetRecord.GetAssetBundleName(path); if (!string.IsNullOrEmpty(assetBundleName)) { string assetName = string.Format("{0}", AssetBundleAssetRecord.GetAssetName(path)); ABsManager.Load(assetBundleName); obj = ABsManager.Instance.loadedAssetBundles[assetBundleName].GetRes(assetName); } return(obj); }
public IEnumerator LoadAssetAsync(string path, System.Action <Object> callback) { path = string.Format(basePath, path.Replace("\\", "/")); string assetBundleName = AssetBundleAssetRecord.GetAssetBundleName(path); ObjectRequest or = FindObjectRequest(path); if (or == null) { or = new ObjectRequest(path, callback); ors.Add(or); yield return(ABsManager.LoadAsync(assetBundleName)); string assetName = string.Format("{0}", AssetBundleAssetRecord.GetAssetName(path)); //yield return ABsManager.Find(assetBundleName).LoadFromMemeroyAsync(); Object obj = ABsManager.Find(assetBundleName).GetRes(assetName); if (or == null) { Debug.LogError("or is removed"); } ; if (or.callbacks != null) { Debug.Log("or callback count = " + or.callbacks.Count + " " + or.path); foreach (var k in or.callbacks) { k(obj); } or.callbacks.Clear(); } ors.Remove(or); } else { or.callbacks.Add(callback); } //if (callback != null) callback(obj); }
public void Load() { m_AssetBundle = ABsManager.LoadInternal(assetbundlename); loaded = true; }
void OnDestroy() { print("absmanager destroy"); m_instance = null; }