public void Play (ulong delay= 0);

参数

delayDelay in number of samples, assuming a 44100Hz sample rate (meaning that Play(44100) will delay the playing by exactly 1 sec).

描述

Plays the clip with an optional certain delay.

该 delay 参数已弃用,请改用更新的 PlayDelayed 函数指定延时(以秒为单位)。

如果 AudioSource.clip 设置为正在播放的同一剪辑, 则该剪辑听起来将像是重新开始播放一样。AudioSource 假设 所有 Play 调用将播放新的音频剪辑。

Note: To obtain sample accuracy with an AudioClip with a different samplerate (than 44.1 khz) you have to do the math yourselves. Delaying an audiosource with an attached AudioClip with samplerate of, say, 32 khz, with 16k samples(.5 sec) is done by Play(22050). ((44100/32000) * 16000 = 22050).

__注意:__AudioSource.PlayScheduled API 可以让您更准确地控制播放音频剪辑的时间。

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { void Start() { AudioSource audio = GetComponent<AudioSource>(); audio.Play(); audio.Play(44100); } }

另请参阅:StopPauseclipPlayScheduled 函数。