The tiny sound library for Unity 3D designed by hww
This is an extremely minimalist version similar to FMOD but much simpler and more compact. Good for small game projects Match3, VR, AR etc. The basic design concept is not to use Unity components, but to use only Assets and some programming.
The system was used for one commercial project which sells worldwide.
The package is available on the openupm registry. You can install it via openupm-cli.
openupm add com.hww.xisound
You can also install via git url by adding this entry in your manifest.json
"com.hww.xisound": "https://github.com/hww/XiSound.git#upm"
Begin with creating the set of your audio events in the project with the right mouse button /Create/XiSound/SimpleAudioEvent Then rename the event and edit it with Unity inspector (see image bellow)
Each event could have a collection of sounds. Those sounds could be played with valious ways.
- Single To play the first sound only
- Sequence To play the next sound every time (incremental mode)
- Random To play in the random order
The first two modes are the best. The Random mode produces allot of problems for QA departament.
The first step of initialization is to create the SoundSystem and the MusicManager
// Assign the AudioEvent with one or more music files
public AudioEvent musicEvent;
// Create the sound system
soundSystem = new SoundSystem(null, null);
// Initialize the music manager
musicManager = new MusicManager(null, musicEvent);
// Initialize the sound system
SoundSystem.PreInitialize();
After initialization the SoundSystem should be updated every frame.
void Update()
{
SoundSystem.OnUpdate(); // Update the sound system
}
There are the next methods in the music manager.
SoundHandle MusicManager.PlayMusic();
SoundHandle MusicManager.PlayMusic(string clipName);
MusicManager.StopMusic();
MusicManager.MusicVolume = 0.5f;
There are the next methods in the SoundSystem class.
// Play the next sound once and call delegate at the end
SoundHandle Play(AudioEvent audioEvent, SoundSource.OnEndDelegate onChangeState = null)
// Play the sound at the position and call delegate at the end.
// Play the next when clipName is null
SoundHandle Play(AudioEvent audioEvent, string clipName, Vector3 position, SoundSource.OnEndDelegate onChangeState = null)
// Control the sound
void StopAllSounds()
void StopAllSound(string eventName)
void FadeOutAllSounds()
void FadeOutAllSounds(string eventName)
When the sound is created and the handle is stored to a variable, the various methods with this sound instance is possible.
// Check if the sound is still exists
bool IsExisting
// Get the Unity sound source
SoundSource GetSource()
// Stop the sound
void Stop()
// Fadeout the sound
void FadeOut()
To move sound source with the object should be used GetSource for the handle.
There is simple example in the XiSound/Example folder.