YaSoundAPI¶
Beta
YaSoundAPI is an interface that controls the way a 2D or 3D audio clip is played.Functions¶
Creates a SoundEntity instance.
entityIf 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.
soundNameThe name of the audio clip you want to playisLoopDetermines whether to the audio clip in loop.delayTimeSpecifies 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.
soundNameThe name of the sound you want to playpositionWorld position of the 3D soundrotationWorld rotation of the 3D rotationisLoopDetermines whether to play the 3D sound in loopdelayTimeSpecifies 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.
soundNameThe name of the sound you want to playpositionWorld position of the 3D soundeulerAngleWorld euler angleisLoopDetermines whether to play the sound in loopdelayTimeSpecifies 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.
soundNameThe name of the sound you want to playfollowTargetThe target object you want the sound to followbonePointDetermines 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.isLoopDetermines whether to play the sound in loopdelayTimeSpecifies how long to delay before starting to play
Plays background music (BGM).
soundNameThe name of the sound you want to playisLoopDetermines whether to play the sound in loopdelayTimeSpecifies how long to delay before starting to play