Files
Virtual-Tutor/Unity/Assets/ARVRMenu.cs
tom.hempel 78e5dcd53e restructure
2025-09-30 18:03:19 +02:00

34 lines
747 B
C#

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class TaskButtonManager : MonoBehaviour
{
[System.Serializable]
public class TaskButton
{
public Button button;
public int sceneIndex;
}
[Header("Assign buttons with their scene indexes")]
public TaskButton[] taskButtons;
private void Start()
{
foreach (var tb in taskButtons)
{
if (tb.button != null)
{
int index = tb.sceneIndex; // capture local copy for lambda
tb.button.onClick.AddListener(() => LoadScene(index));
}
}
}
private void LoadScene(int index)
{
SceneManager.LoadScene(index);
}
}