SoundManager
SoundManager is your interface to using the audio features in Hard Times. You can call it to play ambient music or to play sounds that have been loaded via mod or internal sounds.
Properties
public static SoundManager instance
Contains a reference to the singleton instance. You can use it to call methods on the global object from any script:
SoundManager.instance.PlayButtonSound();
public AudioSource musicSource
Contains a reference to the AudioSource attached to the camera and used to play music.
public AudioSource audioSource
Contains a reference to the AudioSource attached to the camera and used to play audio fx.
public AudioSource sceneBgSoundsSource
Contains a reference to the AudioSource attached to the camera and used to play background ambient sounds.
public float MusicVolume
Contains the actual global music volume value. It's value expressed in a range from 0 to 1.
SoundManager.instance.MusicVolume = 0.5f;
public float AudioVolume
Contains the actual global audio fx volume value. It's value expressed in a range from 0 to 1.
SoundManager.instance.AudioVolume = 0.5f;
Public Methods
public void PlayMusic(AudioClip audioClip)
Immediately starts playing music from the AudioClip passed as a parameter
public void PlayMusic(string musicClip = "")
Immediately starts playing music searching from known audio files a file containing the name passed as a string.
public void StopMusic()
Immediately stops any playing music.
public void StopMusicFadeOut(float fadeTime = 2f)
Stops any playing music with a fadeout effect of the given length in seconds.
public void PlayMusicFadeIn(string musicClip, float duration = 1f)
Starts playing the clip referred by the passed clip name as a string, with a fade in effect of the given length in seconds.
public void PlaySound(AudioClip audioClip)
Immediately plays the passed AudioClip.
public void PlaySound(string audioClip)
Immediately plays a file containing the name passed as a string, searched from known audio files.
public void PlayButtonSound()
A shortcut function which plays the default button sound.
public void PlayErrorSound()
A shortcut function which plays the default button sound.
public void StopSound()
Immediately stops any fx sound which may be playing.
public static AudioClip LoadAudioclip(string audioClipName)
Get a clip name in string format and returns an AudioClip, from the loaded clips.