30 lines
654 B
C#
30 lines
654 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();
|
|
}
|
|
public void Stop()
|
|
{
|
|
source.Stop();
|
|
}
|
|
}
|