Add Text to Image in Code

Hello,

I am creating an extension for editor which should work like this:

  1. User chooses an image
  2. User enters a text, chooses font, color
  3. User clicks button and script adds entered text into the image and saves new image in Assets folder.

So my problem that i can’t find a solution which would easily convert text into Texture2D (or something like that which i can add to image later). I’ve been trying many things but nothing has worked for me.

Please help!
Thank you :slight_smile:

Just easy one solution off the top of my head would be To render it on another camera , image with a text overlay and then screen grab it ?

Well, i am creating an extension so it has to be done only with script. Without using camera or prefabs.

So it’s sort of like an art programme where you have the start layer of your picture/texture etc & you write over it on a new layer & then when you save it merges them into the one texture?

Your description is too complicated :slight_smile: i want to just add a text to image. I know how to merge two images into one. I need just method to convert TextMesh (or something like that) into a Texture2D object and using only script.

Ok, not to sure then. Could you create it as a sprite & access it from there?

You’ll have to read the CharacterInfo from the font, and use the uvs to GetPixel from the font bitmap