Example #1
0
    public void PlayClip(AudioClip clip, AudioChannel channel, float volume = 1, bool loop = false)
    {
        channel.gameObject = new GameObject();
        channel.gameObject.AddComponent <AudioSource>();
        AudioSource source = channel.gameObject.GetComponent <AudioSource>();

        channel.Add(source);
        source.clip   = clip;
        source.loop   = loop;
        source.volume = masterVolume * volume * channel.volume;
        source.Play();
        if (!loop)
        {
            Destroy(channel.gameObject, clip.length);
        }
    }
Example #2
0
    public void PlayClip(AudioClip clip, AudioChannel channel, float volume = 1, bool loop = false)
    {
        this.gameObject.AddComponent <AudioSource>();
        AudioSource source = this.gameObject.GetComponent <AudioSource>();

        channel.Add(source);
        Debug.Log(channel.name + clip.name + source.name);
        source.clip   = clip;
        source.loop   = loop;
        source.volume = masterVolume + volume + channel.volume;
        source.Play();
        if (!loop)
        {
            Destroy(source, clip.length);
        }
    }