2013-05-14 55 views
2

上個月,我一直在與Unity和Vuforia合作爲Android /平板電腦創建增強現實遊戲。我一直在進行團結專家的試用,並且從今天起我有了一個完整的團隊專業許可證。現在我不知道它是否與從試驗到完全更改有關,但自從出現錯誤以來:Vuforia&Unity閱讀像素框架

ReadPixels被調用以從系統幀緩衝區讀取像素,而不是在繪圖框內。 UnityEngine.Texture2D:ReadPixels(Rect,Int32,Int32,布爾值)WebCamImpl:GetPixels32AndBufferFrame(Int32)(在Assets/Qualcomm增強現實/腳本/內部/ WebCamImpl.cs:250)QCARManagerImpl:InjectCameraFrame()(在Assets/Qualcomm增強現實QCARManagerImpl:Update(ScreenOrientation)(在Assets/Qualcomm增強現實/腳本/內部/ QCARManagerImpl.cs:195)QCARBehaviour:Update()(在Assets/Qualcomm增強現實/腳本/ QCARBehaviour.cs:418)

試圖讀取像素越界

讓我無法在編輯器中運行遊戲。當我將它構建到我的android或開關平臺到PC時,它工作正常。但是,這需要很多時間,我真的想在編輯器中進行bug測試,而不是每次構建時都想測試新的東西。

我已經嘗試了很多東西(完成新項目,導出和導入包以及添加外部攝像頭)。

(另:即時得到一個網絡攝像頭輪廓NOG從WebCamBehaviour腳本發現錯誤,可能有一些用它做)提前

感謝,

Twei

回答

0

必須使用WaitForEndOfFrame ()在使用ReadPixels()之前。 Like here:

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();}