delay | Delay 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.
The delay parameter is deprecated, please use the newer PlayDelayed function instead which specifies the delay in seconds.
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).
Note: The AudioSource.PlayScheduled API will give you more accurate control over when the audio clip is played.
#pragma strict @RequireComponent(AudioSource) function Start() { var audio: AudioSource = GetComponent.<AudioSource>(); audio.Play(); audio.Play(44100); }
using UnityEngine; using System.Collections;
[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { void Start() { AudioSource audio = GetComponent<AudioSource>(); audio.Play(); audio.Play(44100); } }
See Also: Stop, Pause, clip and PlayScheduled functions.
Did you find this page useful? Please give it a rating: