Version: 2022.1
public bool isPlaying ;

描述

当前正在播放该 clip 吗?(只读)

**注意:**当调用 AudioSource.Pause() 时,AudioSource.isPlaying 将返回 false。再次使用 AudioSource.Play() 时,将返回 true。

// When the audio component has stopped playing, play otherClip
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public AudioClip otherClip; AudioSource audioSource;

void Start() { audioSource = GetComponent<AudioSource>(); }

void Update() { if (!audioSource.isPlaying) { audioSource.clip = otherClip; audioSource.Play(); } } }