纳金网

标题: Unity3d 调用外部视频 [打印本页]

作者: 艾朵儿    时间: 2012-10-26 10:29
标题: Unity3d 调用外部视频
movieTexture.js

public var url="file:///c:/sample.ogg";  
  
function Start ()  
{  
url="file:///" + Application.dataPath + "/video/sample.ogg";  
print(url);  
// Start download  
var www = new WWW(url);  
// Make sure the movie is ready to start before we start playing  
var movieTexture = www.movie;  
print("downloading...");  
while (!movieTexture.isReadyToPlay)  
{  
    print(www.progress);  
    yield;  
}  
print("download complete");  
print(www.url);  
  
// 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)  

作者: may    时间: 2012-10-26 21:39
过来学习学习




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5