代码用于控制音频源
发布时间
阅读量:
阅读量
1、代码控制播放与停止功能
> 1. public class AudioTest : MonoBehaviour{
>
> 2.
>
> 3. AudioSource audioSource;
>
> 4.
>
> 5. private void Start() {
>
> 6. audioSource = this.GetComponent<AudioSource>();
>
> 7. }
>
> 8.
>
> 9. private void Update() {
>
> 10. if (Input.GetKeyDown(KeyCode.A)) {
>
> 11. // 播放,如果暂停则在暂停后继续播放
>
> 12. audioSource.Play();
>
> 13. // audioSource.PlayDelayed(5); // 延迟 5 秒后播放
>
> 1
全部评论 (0)
还没有任何评论哟~
