Files
BeatSaber/Assets/VRBeatsKit/Scripts/Core/AudioManager.cs
T
whdwo798 2f6aff7691 feat: Game scene — SongController bridges custom map to VRBeatsKit
- SongController: loads MP3 + Beat Saber JSON map, runs countdown (3→2→1→GO),
  spawns cubes via VR_BeatManager.Spawn() synced to audioSource.time
- NoteData → SpawnEventInfo mapping: position/lineLayer → x/y, colorType → ColorSide,
  cutDirection → Direction enum
- travelTimeOverride on SpawnEventInfo: each cube's travel time is back-calculated
  from remaining time at spawn moment, so simultaneous notes arrive at hit zone together
  regardless of frame-level spawn delay
- AudioManager: add PlayClip(AudioClip) and CurrentTime property
- VR_BeatManager: respect travelTimeOverride when non-zero
- Settings.asset: targetTravelTime 0.5 → 1.8 for natural Beat Saber approach feel
- SceneBuilder ④: auto-builds Game.unity from SaberStyle, wires SongController refs,
  registers in Build Settings
- LiberationSans SDF fallback updated with NanumGothic for Korean text support
- Remove unused SampleScene

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 14:32:25 +09:00

56 lines
1.4 KiB
C#

using UnityEngine;
using UnityEngine.Audio;
using Platinio.TweenEngine;
namespace VRBeats
{
[RequireComponent(typeof(AudioSource))]
public class AudioManager : MonoBehaviour
{
[SerializeField] private AudioMixerGroup mixerGroup = null;
[SerializeField] private float fadeOutTime = 4.0f;
private AudioSource audioSource = null;
private void Start()
{
audioSource = GetComponent<AudioSource>();
audioSource.outputAudioMixerGroup = mixerGroup;
ResetThisComponent();
}
private void ResetThisComponent()
{
SetAudioMixerPitch(1.0f);
gameObject.CancelAllTweens();
}
public BaseTween BlendAudioMixerPitch(float from ,float to)
{
return PlatinioTween.instance.ValueTween(from , to , fadeOutTime).SetEase(Ease.EaseOutExpo).SetOnUpdateFloat(delegate (float v)
{
if(audioSource != null)
SetAudioMixerPitch(v);
}).SetOwner(gameObject);
}
public void SetAudioMixerPitch(float value)
{
audioSource.outputAudioMixerGroup.audioMixer.SetFloat("Pitch", value);
}
public void PlayClip(AudioClip clip)
{
audioSource.clip = clip;
audioSource.Play();
}
public float CurrentTime => audioSource != null ? audioSource.time : 0f;
}
}