Version: 2017.3
public void Play (ulong delay= 0);

参数

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.

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

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 函数。

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