mirror of
https://github.com/ConjureETS/Unity_Utils.git
synced 2026-03-24 04:50:58 +00:00
24 lines
701 B
C#
24 lines
701 B
C#
using UnityEngine;
|
|
using Util.CustomTypes;
|
|
|
|
namespace Util.ScriptableObjects.Audio
|
|
{
|
|
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
|
|
public class SimpleAudioEvent : AudioEvent
|
|
{
|
|
public AudioClip[] clips;
|
|
public RangedFloat volume;
|
|
|
|
[MinMaxRange(0, 2)] public RangedFloat pitch;
|
|
|
|
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();
|
|
}
|
|
}
|
|
} |