개발/Unity

문제해결)Unity)ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.

테샤르 2022. 11. 2. 23:04

ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.

 

UnityEngine.Texture2D:ReadPixels (UnityEngine.Rect,int,int)

를 사용하는 과정에서 발생한 이슈이다.

 

반응형

 

텍스쳐를 생성하고 ReadPixels을 하는 과정에서 발생한 오류로 

 

모두 다 그려지고 난 이후에 ReadPixels을 해줘야하는데 그렇지 않은 경우이다.

이 과정을 방지하기 위해서는 ReadPixels를 하기전에 WaitForEndOfFrame을 호출해주면 된다.

 

public IEnumerator TakeSnapShotAndSave()
{
	...
    yield return new WaitForEndOfFrame();
    
    ...
    Texture2D texture = new Texture2D(width, height, TextureFormat.RGB24, false);
    texture.ReadPixels(pixelsRect, 0, 0);
    
    ...
}

 

 

★☆☆☆☆

 

반응형