private IEnumerator loadScene() { yield return(SceneManager.LoadSceneAsync(SceneNames[(int)NextFlow])); _OnChangeFlowEvent?.Invoke(true); switch (_State) { case FlowState.NextAsyncLoading: { FlowHistory.Add(NextFlow); if (FlowHistory.Count >= _FLOW_HISTORY_NUM) { FlowHistory.RemoveAt(0); } } break; case FlowState.BackAsyncLoading: { FlowHistory.RemoveAt(FlowHistory.Count - 1); } break; } _State = FlowState.Idle; CurrentFlow = NextFlow; NextFlow = Flow.None; }
public void NextAsync(Flow nextFlow, onChangedFlow onChanged = null) { bool isFailed = false; isFailed = isFailed | _State != FlowState.Idle; isFailed = isFailed | (((int)nextFlow < 0) || ((int)nextFlow >= SceneNames.Length)); if (isFailed) { onChanged?.Invoke(false); return; } _OnChangeFlowEvent = onChanged; _State = FlowState.NextAsyncLoading; NextFlow = nextFlow; StartCoroutine(loadScene()); }
public void BackAsync(onChangedFlow onChanged = null) { bool isFailed = false; isFailed = isFailed | _State != FlowState.Idle; isFailed = isFailed | (FlowHistory.Count < 1); if (isFailed) { onChanged?.Invoke(false); return; } int index = FlowHistory.Count - 1; var next = FlowHistory[index]; _OnChangeFlowEvent = onChanged; _State = FlowState.BackAsyncLoading; NextFlow = next; StartCoroutine(loadScene()); }