SoundManager Functions

Reference of all the functions accessible in SoundManager.Instance

The SoundManager is the master object which is used to play sounds and manage global settings. An instance in the scene is required to play SoundEvents. You can either add the pre-made prefab called “SoundManager” or add the “Sonity - Sound Manager” component to an empty GameObject in the scene.

Example code:

using UnityEngine;
using Sonity;

public class PlayStopExample : MonoBehaviour {

    public SoundEvent soundEvent;

    void PlayExample() {
        // Plays the SoundEvent at the position of the transform
        SoundManager.Instance.Play(soundEvent, transform);
    }

    void StopExample() {
        // Stops the SoundEvent playing at the transform
        SoundManager.Instance.Stop(soundEvent, transform);
    }
}

Play

Parameters

soundEvent

The SoundEvent to play

owner

The owner Transform

localSoundTag

The SoundTag which will determine the Local SoundTag of the SoundEvent

soundParameterInternals

For example SoundParameterVolumeDecibel is used to modify how the SoundEvent is played

PlayAtPosition

Parameters

soundEvent

The SoundEvent to play

owner

The owner Transform

position

The Transform or Vector3 where is should play at (Transform can follow position)

localSoundTag

The SoundTag which will determine the Local SoundTag of the SoundEvent

soundParameterInternals

For example SoundParameterVolumeDecibel is used to modify how the SoundEvent is played

Stop

Parameters

soundEvent

The SoundEvent to stop

owner

The owner Transform

position

The position Transform

allowFadeOut

If the SoundEvent should be allowed to fade out. Otherwise it is going to be stopped immediately

Pause and Unpause

Parameters

soundEvent

The SoundEvent to pause/unpause

owner

The owner Transform

forcePause

If the SoundEvent should be paused even if it is set to "Ignore Local Pause"

Get State, Length, Time and Contains Loop

Parameters

soundEvent

The SoundEvent to get length or time from

owner

The owner Transform

pitchSpeed

Determines if it should be scaled by pitch. E.g. -12 semitones will be twice as long

Get Spectrum Data

Parameters

soundEvent

The SoundEvent to get the spectrum data from

owner

The owner Transform

samples

The array to populate with audio samples. Its length must be a power of 2

channel

The channel to sample from

window

The FFTWindow type to use when sampling

spectrumDataFrom

Where to get the spectrum data from

Get Last Played AudioSource

Parameters

soundEvent

The SoundEvent to get the AudioSource from

owner

The owner Transform

Load or Unload Audio Data

UI

Useful if you want to play SoundEvents without passing an owner.

UI Play

Parameters

soundEvent

The SoundEvent to play

localSoundTag

The SoundTag which will determine the Local SoundTag of the SoundEvent

soundParameterInternals

For example SoundParameterVolumeDecibel is used to modify how the SoundEvent is played

position

The Transform or Vector3 where is should play at (Transform can follow position)

UI Stop

Parameters

soundEvent

The SoundEvent to stop

allowFadeOut

If the SoundEvent should be allowed to fade out. Otherwise it is going to be stopped immediately

UI Pause and Unpause

Parameters

soundEvent

The SoundEvent to pause/unpause

forcePause

If the SoundEvent should be paused even if it is set to "Ignore Local Pause"

UI Get State, Length and Time

Parameters

soundEvent

The SoundEvent to get length or time from

pitchSpeed

Determines if it should be scaled by pitch. E.g. -12 semitones will be twice as long

Music

Useful if you want to play music with automatic stopping of the old music when playing a new song.

Music Play

Parameters

soundEvent

The SoundEvent to play

stopAllOtherMusic

If all other SoundEvents played at the SoundManager music Transform should be stopped

allowFadeOut

If the other stopped SoundEvent should be allowed to fade out. Otherwise they are going to be stopped immediately

soundParameterInternals

For example SoundParameterVolumeDecibel is used to modify how the SoundEvent is played

Music Stop

Parameters

soundEvent

The SoundEvent to stop

allowFadeOut

If the other stopped SoundEvent should be allowed to fade out. Otherwise they are going to be stopped immediately

Music Pause and Unpause

Music Get State, Length and Time

Parameters

soundEvent

The SoundEvent to get length or time from

pitchSpeed

Determines if it should be scaled by pitch. E.g. -12 semitones will be twice as long

Global Pause and Unpause

Global Volume

Global SoundTag

Global Distance Scale

Speed Of Sound

Voice Limit

Disable Playing Sounds

Get Addressable AudioMixer

Last updated