I would like to render a scene in 3D, then create a texture from the rendered scene using ReadPixels() and finally draw UI elements on top of the 3D render using SetActive(true) on given UI elements.
What is the best method for this? I’m using C# and free version so RenderToTexture() is not available unfortunately.
That was surprisingly easy, WaitFortheEndOfFrame() helps one to stage drawing quite easily. This is from the back of my head how I did it - I’ll make sure this works asap.
Texture2D mytex;
void myRenderingFunc()
{
// do the 3D transformations etc here
// ...
StartCoroutine(phasedDraw());
}
IEnumerator phasedDraw())
{
// wait for the frame be rendered
yield return new WaitForEndOfFrame();
// Read the pixels to texture
mytex = ReadPixels(new Rect(0,0,Screen.width, Screen.height), 0,0);
// Now set the UI elements active
myUIGameObject.SetActive(true);
}