Description
The UI
property of the SoundEvent
class indicates whether the sound is a 2D sound, typically used for user interface elements. When set to true
, the sound is played as a 2D sound, meaning it is not affected by the 3D spatial positioning and will sound the same regardless of the listener's position in the game world.
Usage
To use the UI
property, simply set it to true
if you want the sound to be played as a 2D sound. This is particularly useful for sounds that are part of the user interface, such as button clicks or notifications, where spatial positioning is not required.
Example
// Example of setting the UI property for a SoundEvent
SoundEvent soundEvent = new SoundEvent();
soundEvent.UI = true; // This sound will be played as a 2D sound
// Further configuration of the sound event
soundEvent.Volume = new RangedFloat(0.5f, 1.0f);
soundEvent.Pitch = new RangedFloat(0.8f, 1.2f);
// Add sound files to the event
soundEvent.Sounds.Add(new SoundFile("click_sound.wav"));