Audio Source components and related APIs, sourceapi

Source: Internet
Author: User

Audio Source components and related APIs, sourceapi

Audio Source:Sound components. It must be used with the Audio Listener. The Main Camera will have the Audio Lisetener by default.

Audio Clip:Sound fragment. Specifies the audio file to be played.

Play On Awake:The game starts playing after it starts running.

Mute:Mute.

Loop:Whether to play cyclically.

Volume:Volume.

Spatial Blend:Space mixing, set the sound to 2D or 3D sound. The distance between a 3D sound and the sound source will affect the size of the sound to be heard, and the 2D sound will not be affected.

Common Methods for starting, stopping, and pausing a video are as follows:

1 public class Test 2 {3 public AudioSource audioSource; 4 5 private void Start () 6 {7 audioSource. play (); // start playing 8 audioSource. stop (); // Stop playing 9 audioSource. pause (); // Pause playing 10} 11}

 

AudioSource. PlayClipAtPoint (AudioClip, Vector3, float ):Specifies a position in the world coordinate system to play a Sound clip.

AudioClip: the audio clip to be played.

Vector3: the position of the video clip.

Float: volume.

Use AudioSource. playClipAtPoint automatically generates an object named "One shot audio" and adds AudioSource and audioclip, multiple objects with the same name are generated when multiple sounds are played at the same time. Playing of each sound does not affect each other. However, the disadvantage is that only the volume, position, and loop can be set. After playing is complete, one shot audio is automatically destroyed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.