HPbarzissou
This commit is contained in:
@@ -1,30 +1,82 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TitleManager : MonoBehaviour
|
||||
{
|
||||
[Header("UI Buttons")]
|
||||
[Header("VR入力設定")]
|
||||
[Tooltip("スタート用の右手トリガー入力(例: XRI RightHand Interaction/Activate など)")]
|
||||
[SerializeField] private InputActionProperty rightTriggerAction;
|
||||
[Tooltip("スタート用の左手トリガー入力(任意)")]
|
||||
[SerializeField] private InputActionProperty leftTriggerAction;
|
||||
|
||||
[Header("UI Buttons(任意)")]
|
||||
[SerializeField] private Button startButton;
|
||||
[SerializeField] private Button exitButton;
|
||||
|
||||
[Header("Scene Settings")]
|
||||
[SerializeField] private string mainGameSceneName = "MainGameScene";
|
||||
|
||||
private bool isStarting = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (startButton != null) startButton.onClick.AddListener(OnStartButtonClicked);
|
||||
if (startButton != null) startButton.onClick.AddListener(StartGame);
|
||||
if (exitButton != null) exitButton.onClick.AddListener(OnExitButtonClicked);
|
||||
}
|
||||
|
||||
private void OnStartButtonClicked()
|
||||
private void OnEnable()
|
||||
{
|
||||
EnableAction(rightTriggerAction);
|
||||
EnableAction(leftTriggerAction);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
DisableAction(rightTriggerAction);
|
||||
DisableAction(leftTriggerAction);
|
||||
}
|
||||
|
||||
private void EnableAction(InputActionProperty prop)
|
||||
{
|
||||
if (prop.action != null) prop.action.Enable();
|
||||
}
|
||||
|
||||
private void DisableAction(InputActionProperty prop)
|
||||
{
|
||||
if (prop.action != null) prop.action.Disable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isStarting) return;
|
||||
|
||||
// トリガー入力の判定(右手または左手)
|
||||
if (IsTriggerPressed(rightTriggerAction) || IsTriggerPressed(leftTriggerAction))
|
||||
{
|
||||
StartGame();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTriggerPressed(InputActionProperty prop)
|
||||
{
|
||||
if (prop.action == null) return false;
|
||||
return prop.action.triggered || prop.action.ReadValue<float>() > 0.5f;
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
if (isStarting) return;
|
||||
isStarting = true;
|
||||
|
||||
if (startButton != null) startButton.interactable = false;
|
||||
Debug.Log("🚀 トリガー入力を検知:メインゲームシーンを読み込みます。");
|
||||
StartCoroutine(LoadSceneRoutine());
|
||||
}
|
||||
|
||||
private void OnExitButtonClicked()
|
||||
public void OnExitButtonClicked()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
|
||||
Reference in New Issue
Block a user