private IEnumerator HandleSync() { foreach (var value in AddressNameSync.Values) { var operation = AddressableAsync.InstantiateAsync(value.ToString(), (go) => { Debug.Log($"开始载入同步资源"); Debug.Log($"{go.name}"); }); yield return(operation); } }
protected override IEnumerator Task() { yield return(new WaitForFixedUpdate()); LogTool.Log($"{TaskName.Value}", LogEnum.TaskLog); label.labelString = "PreLoad"; AddressableAsync.InitializeAsync(() => { AddressableAsync.LoadAssetsAsync <object>(label, null, (completed) => { LogTool.Log($"资源预加载完成", LogEnum.TaskLog); IsFinish = true; }); }); }
protected override void InitTask() { LogTool.Log($"{TaskName.Value}", LogEnum.TaskLog); label.labelString = LabelName; AddressableAsync.LoadAssetsAsync <GameObject>(label, (go) => { LogTool.Log($"{go.name}"); AddressableUtil.InstantiateGo(go, true); }, (completed) => { if (completed.Status == AsyncOperationStatus.Succeeded) { LogTool.Log($"资源加载完成", LogEnum.TaskLog); IsFinish = true; } }); }
public override void OnEnter() { base.OnEnter(); Resources.UnloadUnusedAssets(); LogTool.Log($"LoadSceneState", LogEnum.State); AddressableAsync.LoadSceneAsync(SceneName, LoadSceneMode.Single, () => { LogTool.Log($"场景切换完成"); foreach (var value in AddressNameAsync.Values) { AddressableAsync.InstantiateAsync(value.ToString(), (go) => { Debug.Log($"开始载入异步资源"); Debug.Log($"{go.name}"); }); } StartCoroutine(HandleSync()); }); }
/// <summary> /// UIRootMgr生成相关的UI界面 /// </summary> /// <param name="name"></param> /// <param name="callback"></param> public void SpawnUI(string name, Action <GameObject> callback = null) { foreach (var ui in closeUIStroe) { if (ui.BaseName == name) { ui.gameObject.SetActive(true); SetUICanvers(ui); InsertUIBase(ui); return; } } AddressableAsync.LoadAssetAsync <GameObject>(name, (go) => { Debug.Log($"UI Asset 加载完成"); if (callback != null) { callback(go); } }); }