58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using HurricaneVR.Framework.Core.UI;
|
|
using Sirenix.OdinInspector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using Zenject;
|
|
|
|
public class LevelMenuUI : MonoBehaviour
|
|
{
|
|
[Inject]
|
|
[ReadOnly]
|
|
private HVRInputModule uiInput;
|
|
|
|
[Inject]
|
|
[ReadOnly]
|
|
private SceneManager sceneManager;
|
|
|
|
[SerializeField]
|
|
private GameObject levelSelection;
|
|
|
|
[SerializeField]
|
|
private GameObject levelSelectionContent;
|
|
|
|
[SerializeField]
|
|
[ReadOnly]
|
|
private Canvas canvas;
|
|
|
|
[SerializeField]
|
|
private GameObject levelItemPrefab;
|
|
|
|
private void Start()
|
|
{
|
|
if (uiInput == null) return;
|
|
|
|
canvas = GetComponent<Canvas>();
|
|
uiInput?.AddCanvas(canvas);
|
|
|
|
UpdateLevelSelection();
|
|
}
|
|
|
|
private void UpdateLevelSelection()
|
|
{
|
|
foreach (Transform transform in levelSelectionContent.transform)
|
|
{
|
|
Destroy(transform.gameObject);
|
|
}
|
|
|
|
foreach (var level in sceneManager.Levels)
|
|
{
|
|
var go = Instantiate(levelItemPrefab);
|
|
go.name = level.name;
|
|
go.transform.SetParent(levelSelectionContent.transform, false);
|
|
go.GetComponent<LevelItemUI>().Setup(level, false);
|
|
}
|
|
}
|
|
}
|