public AudioClip audioClip ;

설명

Returns the AudioClip belonging to the MovieTexture.

Note that this is a special AudioClip which will always play its audio synchronized to the movie. If you attach a Movie's audioClip to a source in the editor, it will start playing automatically when the movie is playing, Otherwise you'll have to start it manually when you start the movie. The clip can only be attached to one single AudioSource.

See Also: Play, DownloadHandlerMovieTexture.

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

[RequireComponent(typeof(GUITexture))] [RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { public string url = "http://www.unity3d.com/Movie/sample.ogg"; IEnumerator Start() { var uwr = UnityWebRequestMultimedia.GetMovieTexture(url); MovieTexture movieTexture = DownloadHandlerMovieTexture.GetContent(uwr); while (!movieTexture.isReadyToPlay) { yield return null; } GUITexture gt = GetComponent<GUITexture>(); gt.texture = movieTexture; transform.localScale = new Vector3(0, 0, 0); transform.position = new Vector3(0.5F, 0.5F, 0); Rect inset = gt.pixelInset; inset.xMin = -movieTexture.width / 2; inset.xMax = movieTexture.width / 2; inset.yMin = -movieTexture.height / 2; inset.yMax = movieTexture.height / 2; gt.pixelInset = inset; AudioSource aud = GetComponent<AudioSource>(); aud.clip = movieTexture.audioClip; movieTexture.Play(); aud.Play(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961