Files
WhaleAdventure_VR/Assets/02_Scripts/Rhythm/RhythmNoteSpawner.cs
2026-06-12 14:57:38 +09:00

20 lines
945 B
C#

using System;
using UnityEngine;
public class RhythmNoteSpawner : MonoBehaviour
{
[SerializeField] private RhythmNoteInstance _notePrefab; // 생성할 노트 프리팹
[SerializeField] private Transform _spawnPoint; // 노트가 생겨나는 위치(미지정 시 자기 위치)
[SerializeField] private Transform _judgmentLine; // 목적지(판정선)
// 노트 프리팹 생성, 목적지·타이밍 주입
public RhythmNoteInstance SpawnNote(Note note, float spawnTime,
Func<float> songTime, Action<RhythmNoteInstance> onMiss = null)
{
Transform origin = _spawnPoint != null ? _spawnPoint : transform;
RhythmNoteInstance instance = Instantiate(_notePrefab, origin.position, origin.rotation, transform);
instance.Setup(origin.position, _judgmentLine.position, spawnTime, note.Time, songTime, onMiss);
return instance;
}
}