Пример #1
0
    /// <summary>
    /// plays the AudioClip with the specified volumeScale and pitch
    /// </summary>
    /// <returns>The sound.</returns>
    /// <param name="audioClip">Audio clip.</param>
    /// <param name="volume">Volume.</param>
    public SMSound playSound(AudioClip audioClip, float volumeScale, float pitch)
    {
        // Find the first SKSound not being used. if they are all in use, create a new one
        SMSound sound = nextAvailableSound();

        sound.PlayAudioClip(audioClip, volumeScale * _soundEffectVolume, pitch);

        return(sound);
    }
Пример #2
0
    /// <summary>
    /// loops the AudioClip. Do note that you are responsible for calling either stop or fadeOutAndStop on the SKSound
    /// or it will not be recycled
    /// </summary>
    /// <returns>The sound looped.</returns>
    /// <param name="audioClip">Audio clip.</param>
    public SMSound playSoundLooped(AudioClip audioClip)
    {
        // find the first SKSound not being used. if they are all in use, create a new one
        SMSound sound = nextAvailableSound();

        sound.PlayAudioClip(audioClip, _soundEffectVolume, 1f);
        sound.SetLoop(true);

        return(sound);
    }