Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
    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());
    }
Exemplo n.º 3
0
    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());
    }