Skip to content

YaSoundAPI

Beta
YaSoundAPI is an interface that controls the way a 2D or 3D audio clip is played.

Functions

SoundEntity YaSoundAPI.Instance(YaEntity entity)Beta
Creates a SoundEntity instance.
  • entity If this entity contains YaPlayableContainerComponent and an audioClip exists in this entity, the audioClip will be played.
YaSoundHandle YaSoundAPI.PlaySound(string soundName, [boolean isLoop], [number delayTime])Beta
Plays a 2D audio clip. There is no playback distance limit.
  • soundName The name of the audio clip you want to play
  • isLoop 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 play
  • position World position of the 3D sound
  • rotation World rotation of the 3D rotation
  • isLoop Determines whether to play the 3D sound in loop
  • delayTime 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 play
  • position World position of the 3D sound
  • eulerAngle World euler angle
  • isLoop Determines whether to play the sound in loop
  • delayTime 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 play
  • followTarget The target object you want the sound to follow
  • bonePoint 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 loop
  • delayTime Specifies how long to delay before starting to play
YaSoundHandle YaSoundAPI.PlayBGM(string soundName, [boolean isLoop], [number delayTime])Beta
Plays background music (BGM).
  • soundName The name of the sound you want to play
  • isLoop Determines whether to play the sound in loop
  • delayTime Specifies how long to delay before starting to play