//public static int finishNum = 0; //int requestNum = 0; //public static int unloadNum = 0; public void Load(AssetBundleTask task) { //requestNum++; //CDebug.LogError("requestNum " + requestNum); //AssetBundleTask task = new AssetBundleTask(abName, OnFinish); task.Begin(); }
private void Begin() { while (tasks.Count > 0) { AssetBundleTask task = tasks.Dequeue(); unloadtasks.Enqueue(task); task.Begin(); } }
public void AddTask(AssetBundleTask task) { if (tasks.Contains(task)) { return; } tasks.Enqueue(task); }
private void LoadRemote(string path, Callback <GameObject> onload, Callback <AssetBundleTask> getTask) { AssetBundleTask task = new AssetBundleTask(path, (ab) => { if (ab == null) { CDebug.LogError("error resource not found (ab is null) remote path " + path); return; } object mainAsset = ab.LoadAsset("assets/resources/" + path + ".prefab"); GameObject go = mainAsset as GameObject; if (go == null) { CDebug.LogError("error resource not found (go is null) remote path " + path); return; } if (onload != null) { onload(go); onload = null; } //object mainAsset = ab.LoadAssetAsync("assets/resources/" + path + ".prefab"); //AppFacade.InitGame.StartCoroutine(LoadAssetAsyncCoroutine(ab, "assets/resources/" + path + ".prefab", (asset) => //{ // if (asset != null) // finish(asset); //})); }); AssetBundleLoad.Instance.Load(task); if (getTask != null) { getTask(task); } }
/// <summary> /// 加载AssetBundle /// </summary> /// <param name="abName">Resources下相对路径</param> public void Load(string abName, Action <AssetBundle> OnFinish) { AssetBundleTask task = new AssetBundleTask(abName, OnFinish); task.Begin(); }