Ejemplo n.º 1
0
    public void Play(string sfx, AudioSource audio = null)
    {
        if (audio == null)
        {
            if (AudioDict[sfx] == null)
            {
                throw new Exception("Audio is not loaded");
            }
        }
        else if (!AudioDict.ContainsKey(sfx))
        {
            AudioDict[sfx] = audio;
        }

        var s = Instantiate(AudioDict[sfx]);

        StartCoroutine(PlaySound(s));
    }