Rendering UnityGUI stuff in render texture

Is there a way to render the GUI layer to a render texture?
I find UnityGUI useful when it comes to text rendering, and basically I would like to “bake” some rendered texts into a render texture, so that I can use them in a 3D world. I don’t want to use TextMesh for this as I would like my text to be wrapped on 3D geometry.

I have been trying to render OnGUI code onto a render texture, but it doesn’t seem to be possible. I tried to create a separate camera, set a render texture as its target, set up the culling masks and add a GUI layer component to it, but I couldn’t successfully have the OnGUI code render to texture instead of screen.

Has anyone tried that before? Any hints appreciated…

Unfortunately you cannot do that. Also, you cannot capture UnityGUI stuff with a camera.

What you could do is: using Texture2D manipulation methods, you could modify your texture content (pixel-by-pixel).

Use Texture.GetPixels and Texture.SetPixels. Keep in mind this method is pretty slow for huge textures.

The GUILayer hasn’t anything to do with OnGUI code. It’s for GUIText and GUITexture objects, so use those instead.

–Eric

He wants to put texture into the 3D world…