Files
WhaleAdventure_VR/Assets/My project/RhythmGame/Scripts/RhythmInputHandler.cs
skrwns304@gmail.com b1e85a5b89 2026-06-19 UI, UI로직
2026-06-19 14:27:40 +09:00

53 lines
1.2 KiB
C#

using UnityEngine;
using UnityEngine.InputSystem;
public class RhythmInputHandler : MonoBehaviour
{
[Header("Reference")]
[SerializeField] private RhythmGameManager rhythmGameManager;
[Header("Keyboard Test")]
[SerializeField] private bool allowKeyboardTest = true;
[SerializeField] private Key testKey = Key.Space;
[Header("Auto Find")]
[SerializeField] private bool autoFindManager = true;
private void Awake()
{
if (rhythmGameManager == null && autoFindManager)
rhythmGameManager = FindFirstObjectByType<RhythmGameManager>();
}
private void Update()
{
if (!allowKeyboardTest)
return;
if (Keyboard.current == null)
return;
if (Keyboard.current[testKey].wasPressedThisFrame)
SubmitHit();
}
public void OnHit(InputValue value)
{
if (value.isPressed)
SubmitHit();
}
public void SubmitHit()
{
if (rhythmGameManager == null)
return;
rhythmGameManager.SubmitHit();
}
public void SetManager(RhythmGameManager manager)
{
rhythmGameManager = manager;
}
}