返回介绍

WWW.movie 影片

发布于 2019-12-18 15:38:47 字数 3642 浏览 1046 评论 0 收藏 0

JavaScript => var movie: MovieTexture;
C# => MovieTexture movie;

Description 描述

Returns a MovieTexture generated from the downloaded data (Read Only).

从下载的数据,返回一个MovieTexture(只读)。

The data must be a movie in Ogg Theora format.

数据必须为一个Ogg Theora格式影片。

Even if the movie is not yet completely downloaded, this returns immediately, allowing you to start playing the partial movie as it downloads.

即使影片仍没有下载完成,也立即返回,允许你开始播放已经下载完成的部分。

See Also: MovieTexture.audioClip.

JavaScript:

var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
function Start () {
	// Start download
	var www = new WWW(url);
 
	// Make sure the movie is ready to start before we start playing 
	var movieTexture = www.movie; 
	while (!movieTexture.isReadyToPlay) 
	yield;
 
	// Initialize gui texture to be 1:1 resolution centered on screen 
	guiTexture.texture = movieTexture;
 
	transform.localScale = Vector3 (0,0,0); 
	transform.position = Vector3 (0.5,0.5,0); 
	guiTexture.pixelInset.xMin = -movieTexture.width / 2; 
	guiTexture.pixelInset.xMax = movieTexture.width / 2; 
	guiTexture.pixelInset.yMin = -movieTexture.height / 2; 
	guiTexture.pixelInset.yMax = movieTexture.height / 2;
 
	// Assign clip to audio source 
	// Sync playback with audio 
	audio.clip = movieTexture.audioClip;
 
	// Play both movie & sound 
	movieTexture.Play(); 
	audio.Play(); 
} 
// Make sure we have gui texture and audio source 
@script RequireComponent (GUITexture) 
@script RequireComponent (AudioSource) 

C#:

using UnityEngine;
using System.Collections;
 
[RequireComponent (typeof (GUITexture))]
[RequireComponent (typeof (AudioSource))]
public class ExampleClass : MonoBehaviour {
 
 
	string url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
	IEnumerator Start () {
		// Start download
		WWW www = new WWW(url);
 
		// Make sure the movie is ready to start before we start playing 
		MovieTexture movieTexture = www.movie; 
		while (!movieTexture.isReadyToPlay) 
			yield return movieTexture;
 
		// Initialize gui texture to be 1:1 resolution centered on screen 
		guiTexture.texture = movieTexture;
		Rect temTex = guiTexture.pixelInset;
		transform.localScale = new Vector3 (0,0,0); 
		transform.position = new Vector3 (0.5f,0.5f,0); 
		temTex.xMin = -movieTexture.width / 2; 
		temTex.xMax = movieTexture.width / 2; 
		temTex.yMin = -movieTexture.height / 2; 
		temTex.yMax = movieTexture.height / 2;
 
		guiTexture.pixelInset = temTex;
 
		// Assign clip to audio source 
		// Sync playback with audio 
		audio.clip = movieTexture.audioClip;
 
		// Play both movie & sound 
		movieTexture.Play(); 
		audio.Play(); 
	} 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文