Ejemplo n.º 1
0
    private void StopAudio(Channel channel, AudioClip clip)
    {
        // Get audioSource
        AudioSource audioSource = channel.GetAudio(clip).audioSource;

        // Null checks
        if (channel == null || clip == null || audioSource == null) return;

        // See if we should disable it
        if (audioSource.isPlaying)
            audioSource.Stop();

        // Remove the audio from the channel
        channel.RemoveAudioSource(audioSource);
    }
Ejemplo n.º 2
0
    private void UpdateAudio(Channel channel, AudioClip clip, float volume, float pitch, bool loop)
    {
        // Null check
        if (channel == null) return;

        // Get variables
        Audio audio = channel.GetAudio(clip);
        if (audio == null) return;
        AudioSource audioSource = audio.audioSource;
        if (audioSource == null) return;

        // Update variables
        audio.volume = volume;
        audio.pitch = pitch;
        audioSource.loop = loop;

        // Update via channel
        channel.SetAudioValues(audio);
    }