Sound

abstract class in Clatter.Unity

Inherits from MonoBehaviour

Abstract base class for playing audio generated by collision events and ClatterManager. See: ImpactSound and ScrapeSound.

A Sound converts Clatter.Core.Samples data into a Unity AudioClip, adds an AudioSource component, and plays the audio.

Static Fields

Name Type Description Default Value
timeout double Timeout and destroy a Sound if it hasn't received new samples data after this many seconds. 0.1
onCreate Sound Invoked when the Sound is created.
spatialize bool If true, spatialize each AudioSource. true

Fields

Name Type Description Default Value
onEnd Action< int > Invoked when the audio ends.

Static Methods

Create< T >

public static T Create< T >(Samples samples, Vector3d position, int id)

Create a new sound.

Name Type Description
samples Samples The audio samples.
position Vector3d The position of the audio source.
id int The audio source ID.

Methods

End

public void End()

Gracefully end the audio and prepare to self-destruct.