You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public class MenuUI : MonoBehaviour {
private VisualElement root;
private VisualElement mainMenu, playMenu, settingsMenu;
private void OnEnable() {
root = GetComponent<UIDocument>().rootVisualElement;
mainMenu = root.Q("main_menu");
playMenu = root.Q("play_menu");
settingsMenu = root.Q("settings_menu");
mainMenu.Q("btn_play").RegisterCallback<ClickEvent>(PlayPressed);
mainMenu.Q("btn_settings").RegisterCallback<ClickEvent>(SettingsPressed);
playMenu.Q("btn_find").RegisterCallback<ClickEvent>(FindPressed);
playMenu.Q("btn_bot").RegisterCallback<ClickEvent>(BotPressed);
PlayPressed(null);
BotPressed(null);
}
private void PlayPressed(ClickEvent evt) {
mainMenu.style.display = DisplayStyle.None;
playMenu.style.display = DisplayStyle.Flex;
}
private void SettingsPressed(ClickEvent evt) {
mainMenu.style.display = DisplayStyle.None;
settingsMenu.style.display = DisplayStyle.Flex;
}
private void FindPressed(ClickEvent evt) {
Debug.Log("Start finding online opponent");
}
private void BotPressed(ClickEvent evt) {
SceneManager.LoadScene("Game");
}
}