protected void EndDialog() { CurrentHandler?.End(); CurrentHandler = null; CurrentState = null; CurrentDialog.OnDialogEnd.Invoke(); CurrentDialog.CleanUp(); CurrentDialog = null; }
protected override void OnTick() { if (IsExiting) { ReturnToPreviousState(); return; } if (NextState) { CurrentHandler?.End(); CurrentHandler = null; var handler = AllHandlers.FirstOrDefault(h => h.Supports(NextState)); if (handler != null) { CurrentState = NextState; CurrentHandler = handler; NextState = null; CurrentHandler.Begin(); } else { Debug.LogError("Unable to handle state", CurrentState); ReturnToPreviousState(); } } else { if (CurrentHandler != null) { CurrentHandler.Tick(); } } }