I’m currently working on a trading card game in Unity. A card is basically a texture displayed on a plane. Now, I’ve a template for those textures and I would like to fill in the stats of the card (numbers and text).
Is there a way to draw text on a texture at runtime? Effectively, this would mean rendering text to the pixels of the texture on the fly. Can this be done?
Generally you would just render the text separately. For a quick start you can use gui text. Long term there are a number of libraries (such as EZ GUI) that handle bitmap fonts. There’s also a few free/open source examples you can find by searching the forums (or the web).
@JohnnyA: So you basically suggest to use a gui text to “overlay” the actual texture? Interesting… I didn’t think of it that way yet. But I have to say that I like the idea, actually. I would have to use 3Dtext objects instead of gui text because my cards are real 3D objects. Working out an appropriate prefab object with the text at the right positions should not be too difficult here but make displaying the card stats really easy - it would boil down to just alter the text of the 3d text objects - I love that idea
thanks for the reply! However, I’m using multiple (grouped) objects now (as described above) which works really well for my purposes, so I will stick with that solution. It is nice to know, though, that there would be an alternative, if needed
Could I know your way to implement it?
I am working with that problem too.
First way is what i mentioned above but it has some problem I think.
And I am thinking of way to draw Text in plugin by using OpenGLES now.
If you did it, could you help me with your solution?
Moved the 3D text until I was satisfied with the position relative to the parent
Saved the parent object as a prefab
This is very limited, because I imagine that it will only work well for flat objects (since I’m working on a trading card game, this is no problem ;)). As soon as there are bumps, edges and corners in your object you will most likely have no other way but to paint directly onto the texture… This solution is basically a “fake” in a sense that it positions an entirely different object in front of an existing one, so it just looks as if a text has been painted on the texture, but in fact, the text just visually overlays the texture.
You mean you didn’t need to draw text on texture and used another way?
But I wanted to know the way to draw 2D text(3D is ok) on texture.
Thanks for your reply.