using System.Collections; using System.Collections.Generic; using UnityEngine; public class SoundPlayer : MonoBehaviour { private AudioSource source; private void Awake() { source = gameObject.AddComponent(); } 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.Play(); } }