2

上个月,我一直在与 Unity 和 Vuforia 合作,为安卓/平板电脑创建增强现实游戏。我一直在使用 unity-pro 试用版,从今天开始我已经获得了完整的 unity pro 许可证。现在我不知道这是否与从试用到完整的更改有关,但是自从我收到错误以来:

调用 ReadPixels 以从系统帧缓冲区读取像素,而不是在绘图帧内。UnityEngine.Texture2D:ReadPixels(Rect, Int32, Int32, Boolean) WebCamImpl:GetPixels32AndBufferFrame(Int32) (在 Assets/Qualcomm Augmented Reality/Scripts/Internal/WebCamImpl.cs:250) QCARManagerImpl:InjectCameraFrame() (在 Assets/Qualcomm Augmented Reality /Scripts/Internal/QCARManagerImpl.cs:452) QCARManagerImpl:Update(ScreenOrientation) (在 Assets/Qualcomm Augmented Reality/Scripts/Internal/QCARManagerImpl.cs:195) QCARBehaviour:Update() (在 Assets/Qualcomm Augmented Reality/Scripts/ QCARBehaviour.cs:418)

试图读取像素越界

让我无法在编辑器中运行游戏。当我将它构建到我的 android 或将平台切换到 pc 时,它工作正常。但这需要很多时间,我真的想在编辑器中继续进行错误测试,而不是每次我想测试新东西时都进行构建。

我已经尝试了很多东西(完成新项目、导出和导入包并添加了外部网络摄像头)。

(另外:我找到了一个网络摄像头配置文件!来自 WebCamBehaviour 脚本的错误,可能与它有关)

提前致谢,

特威

4

1 回答 1

0

在使用 ReadPixels() 之前,您必须使用 WaitForEndOfFrame()。像这儿:

private IEnumerator RPixels(){
    yield return new WaitForEndOfFrame();
    // Create a texture the size of the screen, RGB24 format
    int width = Screen.width;
    int height = Screen.height;
    Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
    // Read screen contents into the texture
    tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
    tex.Apply();}
于 2015-06-11T08:20:04.550 回答