This commit is contained in:
2026-05-30 09:16:35 +07:00
parent 2f87ce19a7
commit 1c0ee6efb7
4001 changed files with 3363438 additions and 1738 deletions

View File

@@ -0,0 +1,36 @@
using UnityEngine;
namespace Invector
{
[RequireComponent(typeof(AudioSource))]
public class vPlayRandomClip : MonoBehaviour
{
public AudioClip[] clips;
public AudioSource audioSource;
public bool playOnStart = true;
#if !UNITY_5_4_OR_NEWER
protected System.Random random;
#endif
void Start()
{
if (!audioSource) audioSource = GetComponent<AudioSource>();
Random.InitState(Random.Range(0, System.DateTime.Now.Millisecond));
if (playOnStart)
{
Play();
}
}
public void Play()
{
if (audioSource)
{
var index = 0;
index = Random.Range(0, clips.Length - 1);
if (clips.Length > 0)
audioSource.PlayOneShot(clips[index]);
}
}
}
}