21 lines
478 B
C#
21 lines
478 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Sounds : MonoBehaviour
|
|
{
|
|
public List<AudioClip> clips;
|
|
|
|
public static void PlaySound(int i)
|
|
{
|
|
GameObject go = new GameObject();
|
|
|
|
var source = go.AddComponent<AudioSource>();
|
|
source.clip = FindObjectOfType<Sounds>().clips[i];
|
|
source.volume = 1f;
|
|
source.loop = false;
|
|
source.playOnAwake = false;
|
|
source.Play();
|
|
}
|
|
}
|