Skip to main content

LoopingSoundEffect

A class in Root.Township, the global namespace.

Plays a sound effect over and over on a fixed timer until cancelled. Stops when disabled.

Constructors​

MemberWhat it is
LoopingSoundEffect()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private bool isLoopingBacking field for IsPlaying.
private int loopingSfxDurationInMillisecondsLoop length in milliseconds, from the seconds value.
private float loopingSfxDurationInSecondsTime between each replay of the sound.
private AudioControl loopingSoundAudioControlAudio control of the last play, used to stop it.
private SoundEffectSet loopSoundEffectThe sound effect to loop.

Properties​

MemberWhat it is
bool IsPlaying { get; }Whether the loop is running.

Methods​

MemberWhat it is
void CancelLoop()Stops looping and stops the playing sound.
void StartLoop()Starts looping the sound.
3 private and internal methods
MemberWhat it is
private void Awake()Converts the loop length to milliseconds.
private async void LoopSound()Plays the sound at this object, waits the loop length, and repeats while looping.
private void OnDisable()Cancels the loop.

Used in​

Members of other types that take, return or hold a LoopingSoundEffect: