Render-to-Texture advice

I need to periodically create dynamic textures with text drawn into them.

I also like to create virtually everything from script.

The textures only need to be generated once each time any of the text is changed, so I was wondering what the control mechanism is for rendering to textures.

Performance is not a big issue as this is a rarity and happens only when loading data.

Following what I’ve grasped of the usual Unity way it would be to:

  1. Identify when text has changed.
  2. Create a camera
  3. Create a render texture
  4. Associate the camera with the render texture
  5. Create the text I need rendered to texture (some fashion of GUI text or maybe text meshes or something)
  6. Setup camera position/lighting (if needed)
  7. Once the texture has been rendered, convert to a Texture2D, dump render texture, dump render to texture camera

I’m curious though, for step 7, do I attach a script to the new camera and simply wait until update is called to know when the texture has been rendered, or is there some direct way to say “Camera::Render” (I doubt.)

Alternatively, am I going about this all wrong given my requirements:

Arbitrary number of textures
Periodic rendering to texture (probably along the lines of once every 5 minutes or so.)

BTW, also looking for advice on drawing Arabic (Chinese/Korean/Vietnamese/Turkish/Greek all seem to be fine on iOS, but Arabic in default font is lacking.)

Thanks!

Hans

You can simply call Render() on the camera you created.
If your camera exists for more than one frame, make sure you disable it, so that it doesn’t try to render during the regular update.

Thanks :slight_smile:

I’m putting all my text rendering into its own layer and it’s nice to know I can just trigger render manually.

Hans