查看: 1058|回复: 1
打印 上一主题 下一主题

Unity3d 调用外部视频

[复制链接]

1446

主题

3

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
30927
精华
3

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-10-26 10:29:04 |只看该作者 |倒序浏览
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)  
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

may    

8830

主题

81

听众

7万

积分

首席设计师

Rank: 8Rank: 8

纳金币
52344
精华
343

最佳新人 热心会员 灌水之王 活跃会员 突出贡献 荣誉管理 论坛元老

沙发
发表于 2012-10-26 21:39:52 |只看该作者
过来学习学习
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-19 07:38 , Processed in 0.057059 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部