Example #1
0
    public void StopPlay(string name)
    {
        Sfx   s = Array.Find(sounds, sound => sound.name == name);
        Music m = Array.Find(music, music => music.name == name);


        if (m == null && s == null)
        {
            Debug.Log("Sound" + name + "Not Found");
            return;
        }
        else if (m == null && s != null)
        {
            if (s.clipsArray.Length > 0)
            {
                s.source.clip = (s.RandomCliptoPlay());
                s.source.Stop();
            }
            else
            {
                if (s != null)
                {
                    s.source.Stop();
                }
            }
        }
        else if (m != null && s == null)
        {
            if (m != null)
            {
                m.source.Stop();
            }
        }
    }