public void Play (ulong delay= 0);

Parameters

delay@param delay Задержка, измеряется в количестве сэмплов, предполагая частотой дискретизации (частотой сэмплирования) 44100 Гц (подразумевая, что Play(44100) обеспечит задержку ровно в 1 секунду).

Description

Проигрывает clip с задержкой перед началом воспроизведения (опционально).

Параметр задержки delay устарел, пожалуйста используйте вместо него более новую функцию PlayDelayed , которая задаёт задержку в секундах.

If AudioSource.clip is set to the same clip that is playing then the clip will sound like it is re-started. AudioSource will assume any Play call will have a new audio clip to 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); } }

See Also: Stop, Pause, clip и PlayScheduled функции.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961