So lately I’ve been getting this “OnRenderImage() possibly didn’t write anything to the destination texture!” warning every time I start up my app. It’s a one time warning (thankfully) so it doesn’t spam me or anything, but I hate seeing warnings for any reason though.
What exactly triggers this warning? What are the conditions that would cause this warning to appear?
It first appeared when I decided to do a hack to work around the VR showDeviceView limitation described in a thread I posted earlier: Any way to get VRSettings.showDeviceView to render into a Render Texture? - Unity Engine - Unity Discussions
The code sorta looks like this:
public class VRCamera : MonoBehaviour
{
private Camera _camera;
private int _frameCount;
public RenderTexture MirrorTexture { get; private set; }
void Awake()
{
_camera = GetComponent<Camera>();
MirrorTexture = new RenderTexture(_camera.pixelWidth, _camera.pixelHeight, 0);
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination);
if (++_frameCount % 2 == 0)
{
Graphics.Blit(source, MirrorTexture);
}
}
}
If I take out the second Blit, the warning goes away. Otherwise I still get the warning even if I do the blit every frame, every other frame (for left eye only), or whatever.