mirror of
https://github.com/ConjureETS/Unity_Utils.git
synced 2026-03-23 20:40:58 +00:00
24 lines
734 B
C#
24 lines
734 B
C#
using JohnsonUtils.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace JohnsonUtils.Audio
|
|
{
|
|
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
|
|
public class SimpleAudioEvent : AudioEvent
|
|
{
|
|
public AudioClip[] Clips;
|
|
public RangedFloat Volume = new (0.9f,1f);
|
|
|
|
[MinMaxRange(0, 2)] public RangedFloat Pitch = new (0.95f,1.05f);
|
|
|
|
public override void Play(AudioSource source)
|
|
{
|
|
if (Clips.Length == 0) return;
|
|
|
|
source.clip = Clips[Random.Range(0, Clips.Length)];
|
|
source.volume = Random.Range(Volume.MinValue, Volume.MaxValue);
|
|
source.pitch = Random.Range(Pitch.MinValue, Pitch.MaxValue);
|
|
source.Play();
|
|
}
|
|
}
|
|
} |