rabidus-test/Assets/SoundPlayer.cs

26 lines
596 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundPlayer : MonoBehaviour
{
private AudioSource source;
private void Awake()
{
source = gameObject.AddComponent<AudioSource>();
}
public void Play(Sound sound)
{
source.clip = sound.Clip;
source.volume = sound.Volume;
source.pitch = sound.Pitch;
source.priority = sound.Priority;
source.playOnAwake = sound.PlayOnAwake;
source.loop = sound.Loop;
source.spatialBlend = sound.Zone;
source.Play();
}
}