public void OpenMenu(MenuBase instance) { if (_menuStack.Count > 0) { if (instance._disableMenuUnderneath) { foreach (var menu in _menuStack) { menu.gameObject.SetActive(false); if (menu._disableMenuUnderneath) { break; } } } Canvas topCanvas = instance.GetComponent <Canvas>(); Canvas prevCanvas = _menuStack.Peek().GetComponent <Canvas>(); topCanvas.sortingOrder = prevCanvas.sortingOrder + 1; } _menuStack.Push(instance); }