当前位置:  开发笔记 > 前端 > 正文

无法通过WWW加载电影

如何解决《无法通过WWW加载电影》经验,为你挑选了0个好方法。

我正在尝试通过网址加载视频,但我仍然遇到同样的错误.我正在使用Unity 5.3和http://docs.unity3d.com/ScriptReference/WWW-movie.html中的示例代码(由于当前示例未编译,因此进行了大量修改).

using UnityEngine;
using System.Collections;

// Make sure we have gui texture and audio source
[RequireComponent (typeof(GUITexture))]
[RequireComponent (typeof(AudioSource))]
public class TestMovie : MonoBehaviour {

    string url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
    WWW www;

    void Start () {
        // Start download
        www = new WWW(url);

        StartCoroutine(PlayMovie());
    }

    IEnumerator PlayMovie(){
        MovieTexture movieTexture = www.movie;

        // Make sure the movie is ready to start before we start playing
        while (!movieTexture.isReadyToPlay){
            yield return 0;
        }

        GUITexture gt = gameObject.GetComponent();

        // Initialize gui texture to be 1:1 resolution centered on screen
        gt.texture = movieTexture;

        transform.localScale = Vector3.zero;
        transform.position = new Vector3 (0.5f,0.5f,0f);
//      gt.pixelInset.xMin = -movieTexture.width / 2;
//      gt.pixelInset.xMax = movieTexture.width / 2;
//      gt.pixelInset.yMin = -movieTexture.height / 2;
//      gt.pixelInset.yMax = movieTexture.height / 2;

        // Assign clip to audio source
        // Sync playback with audio
        AudioSource aud = gameObject.GetComponent();
        aud.clip = movieTexture.audioClip;

        // Play both movie & sound
        movieTexture.Play();
        aud.Play();

    }

}

我在新场景中将其作为脚本添加到主摄像头,我收到此错误:

Error: Cannot create FMOD::Sound instance for resource (null), (An invalid parameter was passed to this function. )
UnityEngine.WWW:get_movie()
c__Iterator4:MoveNext() (at Assets/TestMovie.cs:20)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
TestMovie:Start() (at Assets/TestMovie.cs:16)

(第20行MovieTexture movieTexture = www.movie;)我已经在这方面工作了一段时间,它发生在许多文件和我的两个系统上.

推荐阅读
牛尾巴2010
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有