Refactor scene management, Enable wasd movement, Add level menu
This commit is contained in:
57
Assets/Scripts/UI/LevelMenuUI.cs
Normal file
57
Assets/Scripts/UI/LevelMenuUI.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user