public void CloseMenu(MenuBase menu) { if (_menuStack.Count == 0) { Debug.Log("MenuStack is empty"); return; } if (_menuStack.Peek() != menu) { Debug.LogErrorFormat(menu, "{0} cannot be closed because it is not on top of stack", menu.GetType()); } CloseTopMenu(); }