找回密码
 立即注册
查看: 5341|回复: 65

[脚本] Unity3D 调用外部视频代码

[复制链接]
发表于 2012-8-13 10:13 | 显示全部楼层 |阅读模式
[code=javascript]
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)   [/code]

movieTexture.js

ogg媒体文件放在:

工程: assets/video

exe: data/video

可以本地访问

参考:

http://unity3d.com/support/docum ... ence/WWW-movie.html

发表于 2017-5-9 09:14 | 显示全部楼层
很不错
发表于 2017-5-9 09:50 | 显示全部楼层
好帖就是要顶
发表于 2017-5-9 09:46 | 显示全部楼层
顶顶多好
发表于 2017-5-9 09:35 | 显示全部楼层
难得一见的好帖
发表于 2017-5-9 09:36 | 显示全部楼层
LZ真是人才
发表于 2017-5-17 11:51 | 显示全部楼层
楼主是超人
发表于 2017-5-17 11:27 | 显示全部楼层
难得一见的好帖
发表于 2017-5-17 11:15 | 显示全部楼层
说的非常好
发表于 2017-5-17 11:28 | 显示全部楼层
很好哦
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-10 15:48 , Processed in 0.098458 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表