Files
ggj2026/Assets/Scripts/WinSceneController.cs
T
2026-01-31 23:21:33 -06:00

39 lines
907 B
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public class WinSceneController : 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 += () => HandleStartClicked("MainMenu");
}
private void HandleStartClicked(string sceneName)
{
if (!string.IsNullOrWhiteSpace(sceneName))
{
SceneManager.LoadScene(sceneName);
}
}
}