diff --git a/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/AvatarCreatorStateMachine.cs b/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/AvatarCreatorStateMachine.cs index c9ac33b8..cd334856 100644 --- a/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/AvatarCreatorStateMachine.cs +++ b/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/AvatarCreatorStateMachine.cs @@ -103,7 +103,7 @@ private void Initialize() private void OnStateChanged(StateType current, StateType previous) { - backButton.gameObject.SetActive(!CanShowBackButton(current)); + backButton.gameObject.SetActive(current != startingState); saveButton.gameObject.SetActive(current == StateType.Editor); if (current == StateType.End) @@ -112,11 +112,6 @@ private void OnStateChanged(StateType current, StateType previous) } } - private bool CanShowBackButton(StateType current) - { - return current == StateType.LoginWithCodeFromEmail || current == StateType.AvatarSelection; - } - public void OnCustomizeDraft(string avatarId) { StartOnCustomize(avatarId, true); diff --git a/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/StateMachine/StateMachine.cs b/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/StateMachine/StateMachine.cs index 49ab0c5a..fdf09094 100644 --- a/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/StateMachine/StateMachine.cs +++ b/Samples~/AvatarCreatorSamples/AvatarCreatorWizard/Scripts/UI/StateMachine/StateMachine.cs @@ -13,7 +13,7 @@ public abstract class StateMachine : MonoBehaviour protected Action StateChanged; private StateType currentState; - + protected void Initialize(List states) { foreach (var state in states) @@ -34,7 +34,7 @@ public void SetState(StateType stateType) SetState(stateTypeMap[stateType].NextState); return; } - + previousStates.Push(previousState); } @@ -56,7 +56,11 @@ public void GoToPreviousState() var previousState = currentState; DeactivateState(stateTypeMap[previousState]); - + + if (previousStates.Count == 0) + { + return; + } currentState = previousStates.Pop(); if (currentState != StateType.None) { @@ -70,7 +74,7 @@ private void ActivateState(State state) state.gameObject.SetActive(true); state.ActivateState(); } - + private void DeactivateState(State state) { state.gameObject.SetActive(false);