SoundSource
A class in Root.Township, the global namespace.
Plays a sound effect on (or at) its object, optionally when enabled, and stops it when disabled. Does nothing when headless.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour - Derived types
AmbienceAudio
Constructors
| Member | What it is |
|---|---|
SoundSource() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected AudioControl audioControl | Handle to the playing sound. |
8 private and internal fields
| Member | What it is |
|---|---|
private bool isStatic | When set, plays at a fixed position instead of following the object. |
private bool isStopped | Set by Stop so a pending play on enable is skipped. |
private SoundEffectSet play | Sound set to play. Filled from the old soundEffect value if empty. |
private bool playOnEnable | Backing field for PlayOnEnable. |
private bool separateStopEffect | When set, Stop plays the stop sound instead of stopping the playing one. |
private SoundEffect soundEffect | Old sound effect value, kept for migration to play. |
private SoundEffectSet stop | Sound set played on stop when separateStopEffect is set. |
private SoundEffect stopEffect | Old stop sound value, kept for migration to stop. |
Properties
| Member | What it is |
|---|---|
bool IsPlaying { get; private set; } | True between Play and Stop. |
bool PlayOnEnable { get; } | Whether it plays when enabled. |
Events
| Member | What it is |
|---|---|
event SoundSourceEvent OnPlay | Fired when the sound starts. |
event SoundSourceEvent OnStop | Fired when the sound stops. |
Methods
1 private and internal method
Used in
Members of other types that take, return or hold a SoundSource: