Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I’ve a small subject with my UI. Each time I click on a button on my pause menu ui nothing occurs even once I hover over the buttons. Nonetheless, in my important menu scene, the UI works with none issues. Evaluating the code facet by facet they’re just about equivalent. I’m additionally utilizing the UI toolkit for my UI as a substitute of the older UI system.

public class PauseMenuUIDocumentManager : MonoBehaviour
{
   non-public static VisualElement pauseMenuContainer;
   non-public Button mainMenuButton;
   non-public Button settingsButton;
   non-public Button quitToDesktopButton;

   public static VisualElement PauseMenuContainer
   {
      get => pauseMenuContainer;
      set => pauseMenuContainer = worth;
   }

   non-public void Begin()
   {
      var root = GetComponent<UIDocument>().rootVisualElement;

      pauseMenuContainer = root.Q<VisualElement>("Background");

      mainMenuButton = root.Q<Button>("MainMenuButton");
      settingsButton = root.Q<Button>("SettingsButton");
      quitToDesktopButton = root.Q<Button>("QuitToDesktop");
      
      mainMenuButton.clicked += MainMenuButtonOnclicked;
      settingsButton.clicked += SettingsButtonOnclicked;
      quitToDesktopButton.clicked += QuitToDesktopButtonOnclicked;

      
   }

   non-public void QuitToDesktopButtonOnclicked()
   {
      Utility.Give up();
   }

   non-public void MainMenuButtonOnclicked()
   {
      Time.timeScale = 1f;
      GameManager.LoadScene("MainMenu");
   }

   non-public void SettingsButtonOnclicked()
   {
      throw new NotImplementedException("This characteristic might be applied later down the road");
   }
}

Right here is my sport supervisor script that really exhibits the pause menu:

if (Enter.GetKeyDown(KeyCode.Escape) && gameIsPaused == false && gameCanBeUnPaused == false)
      {
         PlayerMovement.MovementEnabled = false;
         gameIsPaused = true;
         Time.timeScale = 0f;
         StartCoroutine(CheckIfGameCanBeUnPaused());
         print("The sport is paused");
         OpenPauseMenu();
      }
non-public void OpenPauseMenu()
   {
      PauseMenuUIDocumentManager.PauseMenuContainer.fashion.show = DisplayStyle.Flex;
   }

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *