public void GoBack(bool addToStack = false) { if (isChangingState) { return; } if (currentType == PanelType.HOMEPANEL) { Application.Quit(); panelStack.Clear(); return; } GUIPanel currentPanel = GetPanel(currentType); if (currentPanel != null) { IBack back = currentPanel.GetComponent <IBack>(); if (back != null) { back.GoBack(); return; } } if (panelStack.Count > 0) { PanelType type = panelStack.Pop(); ChangeState(type, addToStack); } else { Application.Quit(); } }