Ejemplo n.º 1
0
    public void Play(string name, float vol)
    {
        AudThingy sownd = new AudThingy();

        foreach (AudThingy t in sounds)
        {
            if (t.name == name)
            {
                sownd = t;
                break;
            }
        }
        var soundList = sownd.soundsList;
        int index     = Random.Range(0, soundList.Length);

        audioSource.clip = soundList[index];
        audioSource.PlayOneShot(soundList[index], vol);
    }
Ejemplo n.º 2
0
    public void Play(string name)
    {
        AudThingy sownd = new AudThingy();

        foreach (AudThingy t in sounds)
        {
            if (t.name == name)
            {
                sownd = t;
                break;
            }
        }
        var soundList = sownd.soundsList;
        int index     = Random.Range(0, soundList.Length);

        if (soundList[index] == null)
        {
            throw new System.Exception("Sound" + index + " not found");
        }
        audioSource.clip = soundList[index];
        audioSource.PlayOneShot(soundList[index], sownd.volume);
    }