SLEAPY_SMURF/Assets/sounds/Sounds.cs

21 lines
478 B
C#
Raw Normal View History

2023-04-30 11:23:57 +00:00
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();
}
}