private void ActivatAndBindSubmenu(Submenu submenu)
 {
     submenu.gameObject.SetActive(true);
     submenu.BackButton.onClick.AddListener(OnBackButtonClicked);
     if (submenu is SubmenuWithNavigationToDifferentSubmenu)
     {
         (submenu as SubmenuWithNavigationToDifferentSubmenu).RequestTransitionToSubmenu += NavigateToMenu;
     }
 }
 private void DeactivatAndUnbindSubmenu(Submenu submenu)
 {
     submenu.gameObject.SetActive(false);
     submenu.BackButton.onClick.RemoveListener(OnBackButtonClicked);
     if (submenu is SubmenuWithNavigationToDifferentSubmenu)
     {
         (submenu as SubmenuWithNavigationToDifferentSubmenu).RequestTransitionToSubmenu -= NavigateToMenu;
     }
 }
 private void NavigateToMenu(Submenu submenu)
 {
     Assert.IsNotNull(submenu, "Null submenu to navigate to on: " + gameObject.name);
     Assert.IsTrue(presentSubmenus.Contains(submenu), "Submenu not present in collected submenus on: " + gameObject.name);
     Assert.IsFalse(submenuStack.Contains(submenu), "Submenu already present on stack on: " + gameObject.name);
     if (submenuStack.Count > 0)
     {
         DeactivatAndUnbindSubmenu(submenuStack.Peek());
     }
     submenuStack.Push(submenu);
     ActivatAndBindSubmenu(submenuStack.Peek());
 }