Unity3d Unity WebCamTexture重新启动

Unity3d Unity WebCamTexture重新启动,unity3d,vuforia,Unity3d,Vuforia,我正在使用以下代码初始化: WebCamDevice[] devices = WebCamTexture.devices; string deviceName = devices[0].name; WebCamTexture wct = new WebCamTexture(deviceName, Constants.BACKGROUND_WIDTH * 2, Constants.BACKGROUND_HEIGHT * 2, 20); backgroundSprite.renderer.mater

我正在使用以下代码初始化:

WebCamDevice[] devices = WebCamTexture.devices;
string deviceName = devices[0].name;
WebCamTexture wct = new WebCamTexture(deviceName, Constants.BACKGROUND_WIDTH * 2, Constants.BACKGROUND_HEIGHT * 2, 20);
backgroundSprite.renderer.material.mainTexture = wct;
wct.Play();
代码的其余部分:

void TakeSnapshot() {
    Texture2D snap = new Texture2D(wct.width, wct.height);
    snap.SetPixels(wct.GetPixels());
    snap.Apply();

    AppManager.Singleton.SetPictureTaken(snap);
}

private void onSnapAction() {
    wct.Pause();
    TakeSnapshot();
    wct.Stop();
    DestroyObject(backgroundSprite);
    DestroyObject(wct);
}
现在,当我尝试重新加载场景时,它崩溃了。我想这是因为相机没有释放出来

我也在拍照后使用vuforia,但这会使应用程序崩溃。然而,当我用我的前置摄像头拍照,用后置摄像头进行图像跟踪时,效果很好。(直到我再次进入摄像头)


提前感谢。

好的,显然问题出在iOS7上,显然他们的视频处理不同,Unity 4.2.1及更低版本还没有解决这个问题。提升我的团结是有效的


看起来相机没有正确释放或被删除(XCode中的BadAccess崩溃)。再次访问它会导致崩溃。统一4.2.2。up对此有一个解决方案。

使用debug查看哪一行崩溃如何?听起来好像相机没有正常释放。我想这应该发生在
wct.Stop()
上,但也许wct中有一个
Dispose()
方法?我们已经将assetstore中一个名为Camera Capture Kit的插件与类似于vuforia的东西结合起来,没有任何问题,它只是开箱即用,也许你应该检查一下。()-也许你可以通过像Resourcse.RemoveAllUnused这样的函数来释放纹理。。。