纳金网

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

作者: 狂风大尉    时间: 2014-6-25 01:30
标题: 调用外部视频脚本
ogg媒体文件放在:
工程: assets/video
exe: data/video
  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. //Unity3D:www.unitymanual.com      
  27. // Assign clip to audio source     
  28. // Sync playback with audio     
  29. audio.clip = movieTexture.audioClip;   

  30. // Play both movie & sound     
  31. movieTexture.Play();   
  32. audio.Play();   
  33. }   
  34. // Make sure we have gui texture and audio source     
  35. @script RequireComponent (GUITexture)   
  36. @script RequireComponent (AudioSource)   
复制代码
      * 版权声明:转载时请以超链接形式标明文章原始出处和作者信息
      * 本文来自:Unity3D 教程手册
      * 本文链接:http://www.unitymanual.com/6835.html

作者: hyui    时间: 2014-6-25 02:23
Thanks for this!
作者: hariboot    时间: 2014-6-25 08:43
这个只支持IOS&ANDROID么
作者: wucnj    时间: 2014-6-25 09:04
感谢分享!!!
作者: HIDEOKOJIMA    时间: 2014-6-25 16:51
感谢分享!




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