YaSoundAPI¶
Beta
YaSoundAPI
is an interface that controls the way a 2D or 3D audio clip is played.Functions¶
Creates a SoundEntity instance.
entity
If this entity containsYaPlayableContainerComponent and an audioClip exists in this entity, the audioClip will be played.
Plays a 2D audio clip. There is no playback distance limit.
soundName
The name of the audio clip you want to playisLoop
Determines whether to the audio clip in loop.delayTime
Specifies how long to delay before starting to play
YaSoundHandle YaSoundAPI.Play3DSound(string soundName, float3 position, quaternion rotation, [boolean isLoop], [number delayTime])Beta
Plays a 3D audio clip at the specified position.
soundName
The name of the sound you want to playposition
World position of the 3D soundrotation
World rotation of the 3D rotationisLoop
Determines whether to play the 3D sound in loopdelayTime
Specifies how long to delay before starting to play
YaSoundHandle YaSoundAPI.Play3DSound(string soundName, float3 position, [float3 eulerAngle], [boolean isLoop], [number delayTime])Beta
Play a 3D audio clip at a specified position.
soundName
The name of the sound you want to playposition
World position of the 3D soundeulerAngle
World euler angleisLoop
Determines whether to play the sound in loopdelayTime
Specifies how long to delay before starting to play
YaSoundHandle YaSoundAPI.Play3DSound(string soundName, YaEntity followTarget, [number bonePoint], [boolean isLoop], [number delayTime])Beta
Play a 3D audio clip that follows a target object in the scene.
soundName
The name of the sound you want to playfollowTarget
The target object you want the sound to followbonePoint
Determines the bone point of the target entity to follow. By default, the parameter is 0, which means the sound follows the root position when the target entity is an avatar. If you set it to 1, the sound follows the left hand. If you set it to 2, the sound follows the right hand. If you set it to 4, the sound follows the head top of the avatar.isLoop
Determines whether to play the sound in loopdelayTime
Specifies how long to delay before starting to play
Plays background music (BGM).
soundName
The name of the sound you want to playisLoop
Determines whether to play the sound in loopdelayTime
Specifies how long to delay before starting to play