set global volume||doc135623

September 20, 2022

Format

 TdAudioEngine:setGlobalVolume(volume)

Description

Set the global volume.


Precautions

To set a new global volume, you can first obtain the original global volume and then set it to determine whether the global volume has been set. This function should be matched with the function that obtains the global volume of the sound effectgetGlobalVolumeto use.


Parameters

Variable name type Description
volume float volume


Code Samples

local TdAudioEngine = TdAudioEngine.Instance()
print(TdAudioEngine:getGlobalVolume())
TdAudioEngine:setGlobalVolume(0.8)
print(TdAudioEngine:getGlobalVolume())
end