using System; using System.Collections.Generic; using UnityEngine; using Random = System.Random; namespace Util { [CreateAssetMenu(fileName = "Effect", menuName = "Effects/EffectData")] public class Effect : ScriptableObject { private static readonly Random RandomSound = new Random(); public List listOfSounds; public GameObject effect; public bool autoDestroy = true; public float liveTime = 1f; public static T ChooseRandom(List list) { if (list == null || list.Count == 0) { throw new ArgumentException($"The list of sounds in Effect should not be empty"); } int index = RandomSound.Next(list.Count); return list[index]; } } }