public void Play (ulong delay= 0);

Parámetros

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

Descripción

Plays the clip.

El parámetro de delay es obsoleto, por favor utilice la nueva función PlayDelayed en su lugar, pues especifica el retraso en segundos.

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.

Nota: El AudioSource.PlayScheduled API le dará a usted más control preciso sobre cuando el clip de audio se reproduce.

using UnityEngine;

// The Audio Source component has an AudioClip option. The audio // played in this example comes from AudioClip and is called audioData.

[RequireComponent(typeof(AudioSource))] public class ExampleScript : MonoBehaviour { AudioSource audioData;

void Start() { audioData = GetComponent<AudioSource>(); audioData.Play(0); Debug.Log("started"); }

void OnGUI() { if (GUI.Button(new Rect(10, 70, 150, 30), "Pause")) { audioData.Pause(); Debug.Log("Pause: " + audioData.time); }

if (GUI.Button(new Rect(10, 170, 150, 30), "Continue")) { audioData.UnPause(); } } }

Mirar también: las funciones Stop, Pause, clip y PlayScheduled.

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