- Added light probes for the future game room. - Added tooltips to TimerSounds variables.
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
|
|
public class TimerSounds : TimerBase
|
|
{
|
|
[SerializeField] private AudioSource _AudioSource;
|
|
[SerializeField] private AudioClip[] _AudioClips;
|
|
[Space]
|
|
[Tooltip("If checked, will loop multiple times. If not checked, will play once after starting the timer and then stop until the timer is restarted.")]
|
|
[SerializeField] private bool _Loop = true;
|
|
[Space]
|
|
[Tooltip("Minimum time in seconds to randomly wait before starting the playback loop")]
|
|
[SerializeField] private float _MinimumStart = 0.0f;
|
|
[Tooltip("Maximum time in seconds to randomly wait before starting the playback loop")]
|
|
[SerializeField] private float _MaximumStart = 1.0f;
|
|
[Space]
|
|
[Tooltip("Minimum time in seconds to randomly wait before continuing the playback loop")]
|
|
[SerializeField] private float _MinimumDelay = 0.0f;
|
|
[Tooltip("Maximum time in seconds to randomly wait before continuing the playback loop")]
|
|
[SerializeField] private float _MaximumDelay = 1.0f;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
TimerLength = Random.Range(_MinimumStart, _MaximumStart);
|
|
}
|
|
|
|
|
|
public override void StopTimer()
|
|
{
|
|
base.StopTimer();
|
|
TimerLength = 0.0f;
|
|
}
|
|
|
|
public override void TimerEvent()
|
|
{
|
|
_AudioSource.Stop();
|
|
AudioClip NextAudioClip = _AudioClips[Random.Range(0, _AudioClips.Length)];
|
|
_AudioSource.clip = NextAudioClip;
|
|
_AudioSource.Play();
|
|
|
|
if (_Loop)
|
|
{
|
|
TimerLength = NextAudioClip.length + Random.Range(_MinimumDelay, _MaximumDelay);
|
|
StartTimer();
|
|
}
|
|
}
|
|
}
|