更改场景时,WebCamTexture崩溃

时间:2016-09-28 16:12:48

标签: c# android unity3d unityscript unity5

我试图使用WebCamTexture在两个场景中显示电话摄像头但是当我在我的Android设备中加载第二个场景时游戏崩溃了。我在相机前面创建了一架飞机(作为电影屏幕),我附上了这个剧本:

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour
{
    public WebCamTexture mCamera;
    public GameObject plane;

    void Start ()
    {
        plane = GameObject.FindWithTag ("PlayerCam");

        mCamera = new WebCamTexture ();
        plane.GetComponent<Renderer>().material.mainTexture = mCamera;
        mCamera.Play ();

    }

}

在Unity编辑器中一切正常,但是当我加载第二个场景时,我的android设备崩溃了。有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

在加载另一个场景之前,您需要销毁WebCamTexture