public var url="file:///c:/sample.ogg"; //文件路径 function Start () { //拼凑一个url url="file:///" + Application.dataPath + "/video/sample.ogg"; print(url); // 开始下载 var www = new WWW(url); // 查看电影是否下载完,如果没有下载完,那么延时 var movieTexture = www.movie; print("downloading..."); while (!movieTexture.isReadyToPlay) { print(www.progress); yield; } print("download complete"); print(www.url); // 初始化gui保证在最中间 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; // 设置一张截图(切片)作为显示,在没有播放的时候 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)