예제 #1
0
    /// <summary> Sets the audio type label of the channel. Useful for dedicating a channel to music, for example. </summary>
    /// <param name='channel'> The AudioMixer channel. Should be a number between 1 and NUM_OF_CHANNELS </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void SetChannelAudioType(int channel, AudioMixerChannelTypes audioType)
    {
        FindAMObject();
        if (!theInstance.ChannelIsValid(channel))
        {
            return;
        }

        theInstance.channelsAudioType[channel - 1] = audioType;
    }
예제 #2
0
    /// <summary> Stops muting every channel assigned the given audio type. </summary>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void UnmuteAllOfType(AudioMixerChannelTypes audioType)
    {
        FindAMObject();

        for (int i = 1; i <= NUM_OF_CHANNELS; i++)
        {
            if (theInstance.channelsAudioType[i - 1] == audioType)
            {
                Unmute(i);
            }
        }
    }
예제 #3
0
    /// <summary> Plays the given sound clip on any channel and marks it as the given audio type. </summary>
    /// <param name='soundClip'> The audio file itself. Handled in Unity as an AudioClip. </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void Play(AudioClip soundClip, AudioMixerChannelTypes audioType)
    {
        // Find avaliable channel
        int avaliableChannel = AudioMixer.FindFirstAvaliableChannel();

        if (avaliableChannel <= 0)
        {
            Debug.LogError("AudioMixer: Finding Avaliable Channel returned an invalid index.");
            return;
        }

        // Play in avaliable channel
        AudioMixer.Play(avaliableChannel, soundClip, audioType);
    }
예제 #4
0
    /// <summary> Pauses every channel assigned the given audio type. Ignores any channel without an assigned AudioClip.
    /// To unpause all channels of the given audio type, use PlayAllOfType(). </summary>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void PauseAllOfType(AudioMixerChannelTypes audioType)
    {
        FindAMObject();

        for (int i = 1; i <= NUM_OF_CHANNELS; i++)
        {
            if (theInstance.channelsAudioType[i - 1] == audioType)
            {
                if (theInstance.channels[i - 1].clip == null)
                {
                    //Debug.Log("AudioMixer.PauseAllOfType: Channel " + (i+1).ToString() + " does not have an assigned AudioClip!");
                    continue;
                }
                Pause(i);
            }
        }
    }
예제 #5
0
    /// <summary> Plays the given sound clip in the given channel and marks it as the given audio type. </summary>
    /// <param name='channel'> The AudioMixer channel. Should be a number between 1 and NUM_OF_CHANNELS </param>
    /// <param name='soundClip'> The audio file itself. Handled in Unity as an AudioClip. </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void Play(int channel, AudioClip soundClip, AudioMixerChannelTypes audioType)
    {
        FindAMObject();
        if (!theInstance.ChannelIsValid(channel))
        {
            return;
        }

        if (soundClip == null)
        {
            Debug.LogWarning("AudioMixer.Play: Specified AudioClip is null. Check if it's assigned somewhere.");
        }

        theInstance.channels[channel - 1].clip     = soundClip;
        theInstance.channelsAudioType[channel - 1] = audioType;

        theInstance.channelsOccupied[channel - 1] = true;
        theInstance.channelsPaused[channel - 1]   = false;
        theInstance.channels[channel - 1].Play();
    }
예제 #6
0
    /// <summary> Mutes only the channels assigned the given audio type. To stop muting, use UnmuteAllOfType(). </summary>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void MuteAllOfType(AudioMixerChannelTypes audioType)
    {
        FindAMObject();

        for(int i=1; i <= NUM_OF_CHANNELS; i++)
        {
            if(theInstance.channelsAudioType[i-1] == audioType)
            {
                Mute(i);
            }
        }
    }
예제 #7
0
    /// <summary> Stops the audio playback in the channels assigned the given audio type. </summary>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void StopAllOfType(AudioMixerChannelTypes audioType)
    {
        FindAMObject();

        for(int i=1; i <= NUM_OF_CHANNELS; i++)
        {
            if(theInstance.channelsAudioType[i-1] == audioType)
            {
                /*
                if(theInstance.channels[i-1].clip == null)
                {
                    //Debug.Log("AudioMixer.StopAllOfType: Channel " + (i+1).ToString() + " does not have an assigned AudioClip!");
                    continue;
                }
                */
                Stop(i);
            }
        }
    }
예제 #8
0
    /// <summary> Sets the audio type label of the channel. Useful for dedicating a channel to music, for example. </summary>
    /// <param name='channel'> The AudioMixer channel. Should be a number between 1 and NUM_OF_CHANNELS </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void SetChannelAudioType(int channel, AudioMixerChannelTypes audioType)
    {
        FindAMObject();
        if(! theInstance.ChannelIsValid(channel) ) return;

        theInstance.channelsAudioType[channel-1] = audioType;
    }
예제 #9
0
    /// <summary> Plays the given sound clip in the given channel and marks it as the given audio type. </summary>
    /// <param name='channel'> The AudioMixer channel. Should be a number between 1 and NUM_OF_CHANNELS </param>
    /// <param name='soundClip'> The audio file itself. Handled in Unity as an AudioClip. </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void Play(int channel, AudioClip soundClip, AudioMixerChannelTypes audioType)
    {
        FindAMObject();
        if(! theInstance.ChannelIsValid(channel) ) return;

        if(soundClip == null)
        {
            Debug.LogWarning("AudioMixer.Play: Specified AudioClip is null. Check if it's assigned somewhere.");
        }

        theInstance.channels[channel-1].clip = soundClip;
        theInstance.channelsAudioType[channel-1] = audioType;

        theInstance.channelsOccupied[channel-1] = true;
        theInstance.channelsPaused[channel-1] = false;
        theInstance.channels[channel-1].Play();
    }
예제 #10
0
    /// <summary> Plays the given sound clip on any channel and marks it as the given audio type. </summary>
    /// <param name='soundClip'> The audio file itself. Handled in Unity as an AudioClip. </param>
    /// <param name='audioType'> Used to label the audio to a specific type. Choose from Sound, Music, Jungle, and Voice. </param>
    public static void Play(AudioClip soundClip, AudioMixerChannelTypes audioType)
    {
        // Find avaliable channel
        int avaliableChannel = AudioMixer.FindFirstAvaliableChannel();

        if(avaliableChannel <= 0)
        {
            Debug.LogError("AudioMixer: Finding Avaliable Channel returned an invalid index.");
            return;
        }

        // Play in avaliable channel
        AudioMixer.Play(avaliableChannel, soundClip, audioType);
    }