Menu

 avatar
unknown
csharp
2 years ago
1.2 kB
2
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class Menu : MonoBehaviour
{
    public bool menu_visible = true;
    public bool continue_click;
    public UIDocument root;
    public Button continueButton;
    public Button settingsButton;
    public Button quitButton;

    void Start() {
        var root = GetComponent<UIDocument>().rootVisualElement;
        continueButton = root.Q<Button>("continueButton");
        settingsButton = root.Q<Button>("settingsButton");
        quitButton = root.Q<Button>("quitButton");

        continueButton.clickable.clicked += () => Debug.Log("Clicked");
    }

    void Update() {
        if(!menu_visible && Input.GetButtonDown("menu")) { 
            print("In-Game Menu Opened");
            menu_visible = true;
            
            //SHOW UI
            root.enabled = true;
 
        } else if(menu_visible && (Input.GetButtonDown("menu") )) {
            print("In-Game Menu Closed");
            menu_visible = false;
            
            //HIDE UI
            root.enabled = false;
        }
    }    
}