Exemplo n.º 1
0
    public void Play(string name)
    {
        soundScript s = Array.Find(sounds, sound => sound.name == name);

        if (s == null)
        {
            Debug.Log("lol f**k you we found no sound");
            return;
        }
        s.source.Play();
    }
Exemplo n.º 2
0
    //to call this function: sound.me.play();
    public void Awake()
    {
        if (me != null)
        {
            Destroy(this);
        }
        me = this;

        sources = new AudioSource[sourceNum];
        for (int i = 0; i < sourceNum; i++)
        {
            sources[i] = ((GameObject)Instantiate(sourcePrefab, Vector3.zero, Quaternion.identity, transform)).GetComponent <AudioSource>();
        }
    }