纳金网

标题: unity载入外部视频脚本 [打印本页]

作者: 王者再临    时间: 2014-12-31 21:48
标题: unity载入外部视频脚本
  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)
复制代码

作者: xizhenlong    时间: 2015-1-16 15:14
这段代码挺有用的啊            




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