restructure
This commit is contained in:
33
Unity/Assets/ARVRMenu.cs
Normal file
33
Unity/Assets/ARVRMenu.cs
Normal file
@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user