Rendering text to Texture

Hi

I have come across this problem a couple of times now, and was wondering if anyone out there had a solution and iv’e just missed it

I need to render text to texture

here are some of the solutions i have already ruled out:

1: Using render texture
while the whole process of rendering the screen to a texture in order to just get a text that is created through GUI seems a little bit overkill it could get the job done and almost makes the use of the pro feature worthwhile, however this feature does not work on mobile platforms so it’s a no go

2: Bitmap font
Atleast there is a SetPixel() function so it would be possible to write a custom bitmap font renderer, we already have a whole library of various windows, gradients and stuff implemented this way. Adding this extra functionality shouldn’t be too much of a hassle IF only the game weren’t in Chinese, even if we narrowed the bitmap font down to the characters that are actually used in the game it would still be HUGE!!

3: Referencing the System.Drawing assembly
.NET provides text rendering, however it’s not referenced as default in Unity, as far as i know this could be achieved with Unity Pro, but i’m afraid the .NET implementation uses GDI, and that will not work on mobile platforms? correct me if i’m wrong

4: Writing a custom font rasterizer
I guess that could be achieved, but then again why a’m i using an Engine?

I found a workaround for this problem, even using the free version, using Unity 4.6 beta.

Go ahead and right-click in the Heirarchy, and select “UI : Button
The system will insert a group of objects : Canvas / Text, Canvas / Button, and EventSystem.
Keep those elements. Make the Button and EventSystem inactive by unchecking them in the Inspector.
Now you have the last visisble element on the screen : the “Text” element.

You can run all kinds of scale, translation, and 3d rotation transforms on this text,
and they will appear properly in perspective in-Game.
Screen-shot attached below:


Enjoy,
G