Files
ggj2026/Assets/Scripts/LoseGuiController.cs
T
2026-02-01 13:21:59 -06:00

38 lines
858 B
C#

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public class LoseGuiController : MonoBehaviour
{
private UIDocument uiDocument;
private Button button;
// Start is called once before the first execution of Update after the MonoBehaviour is created
private void OnEnable()
{
uiDocument ??= GetComponent<UIDocument>();
if (uiDocument == null)
{
return;
}
var root = uiDocument.rootVisualElement;
if (root == null)
{
return;
}
button = root.Q<Button>("Button");
button.clicked += () => HandleClick("MainMenu");
}
private void HandleClick(string sceneName)
{
if (!string.IsNullOrWhiteSpace(sceneName))
{
SceneManager.LoadScene(sceneName);
}
}
}