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

[其他] unity载入外部视频脚本

[复制链接]

2317

主题

54

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
20645
精华
62

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

跳转到指定楼层
楼主
发表于 2014-12-31 21:48:52 |只看该作者 |倒序浏览
  1. public var url=“file:///c:/sample.ogg”;

  2. function Start ()

  3. {

  4. url=“file:///” + Application.dataPath + “/video/sample.ogg”;

  5. print(url);

  6. // Start download

  7. var www = new WWW(url);

  8. // Make sure the movie is ready to start before we start playing

  9. var movieTexture = www.movie;

  10. print(“downloading...”);

  11. while (!movieTexture.isReadyToPlay)

  12. {

  13. print(www.progress);

  14. yield;

  15. }

  16. print(“download complete”);

  17. print(www.url);

  18. // Initialize gui texture to be 1:1 resolution centered on screen

  19. guiTexture.texture = movieTexture;

  20. transform.localScale = Vector3 (0,0,0);

  21. transform.position = Vector3 (0.5,0.5,0);

  22. guiTexture.pixelInset.xMin = -movieTexture.width / 2;

  23. guiTexture.pixelInset.xMax = movieTexture.width / 2;

  24. guiTexture.pixelInset.yMin = -movieTexture.height / 2;

  25. guiTexture.pixelInset.yMax = movieTexture.height / 2;

  26. // Assign clip to audio source

  27. // Sync playback with audio

  28. audio.clip = movieTexture.audioClip;

  29. // Play both movie & sound

  30. movieTexture.Play();

  31. audio.Play();

  32. }

  33. // Make sure we have gui texture and audio source

  34. @script RequireComponent (GUITexture)

  35. @script RequireComponent (AudioSource)
复制代码
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

0

主题

1

听众

939

积分

初级设计师

Rank: 3Rank: 3

纳金币
330
精华
0

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

沙发
发表于 2015-1-16 15:14:18 |只看该作者
这段代码挺有用的啊            
回复

使用道具 举报

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

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

GMT+8, 2025-7-25 21:47 , Processed in 0.061612 second(s), 32 queries .

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

© 2008-2019 Narkii Inc.

回顶部