Refactor scene management, Enable wasd movement, Add level menu
This commit is contained in:
@@ -28,10 +28,6 @@ public class HandMenuUI : MonoBehaviour
|
||||
[ReadOnly]
|
||||
private Canvas canvas;
|
||||
|
||||
private float smoothTime = 0.3F;
|
||||
private Vector3 velocity = Vector3.zero;
|
||||
private float forwardOffset = 0.5f;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI titleText;
|
||||
|
||||
@@ -70,6 +66,9 @@ public class HandMenuUI : MonoBehaviour
|
||||
[SerializeField]
|
||||
private GameObject settings;
|
||||
|
||||
private float forwardOffset = 0.7f;
|
||||
private float upOffset = -0.3f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (uiInput == null) return;
|
||||
@@ -92,14 +91,13 @@ public class HandMenuUI : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//UpdatePosition();
|
||||
CheckInput();
|
||||
}
|
||||
|
||||
private void UpdatePosition()
|
||||
{
|
||||
var targetPosition = lookAt.position + (lookAt.forward * forwardOffset);
|
||||
transform.position = new Vector3(targetPosition.x, lookAt.position.y, targetPosition.z);
|
||||
transform.position = new Vector3(targetPosition.x, lookAt.position.y + upOffset, targetPosition.z);
|
||||
|
||||
var lookAtPositon = new Vector3(lookAt.position.x, transform.position.y, lookAt.position.z);
|
||||
transform.rotation = Quaternion.LookRotation(transform.position - lookAtPositon);
|
||||
|
||||
38
Assets/Scripts/UI/LevelItemUI.cs
Normal file
38
Assets/Scripts/UI/LevelItemUI.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LevelItemUI : MonoBehaviour
|
||||
{
|
||||
[ReadOnly]
|
||||
[SerializeField]
|
||||
private Level level;
|
||||
|
||||
[ReadOnly]
|
||||
[SerializeField]
|
||||
private bool isLocked;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI difficultyText;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI nameText;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI descriptionText;
|
||||
|
||||
[SerializeField]
|
||||
private Image backgroundImage;
|
||||
|
||||
public void Setup(Level level, bool isLocked)
|
||||
{
|
||||
this.level = level;
|
||||
this.isLocked = isLocked;
|
||||
|
||||
nameText.text = level.levelName;
|
||||
difficultyText.text = "0";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/LevelItemUI.cs.meta
Normal file
11
Assets/Scripts/UI/LevelItemUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 206bb935443c1d243ad35d3a7e349de1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/LevelMenuUI.cs.meta
Normal file
11
Assets/Scripts/UI/LevelMenuUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad9a6ec509c78a8498dcfad96bc9e8a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user