Using Image Mask to apply a texture to Text

I’m working on a heavily UI focused game, that uses a sort of weathered paper look, so we want Text to have a nice textured look to them. The easiest way I’ve found is to apply a sprite Mask to Text objects as a means of giving it some texture, using this hierarchy:

  • GameObject with Text and Mask components:
    2227671--148378--Screenshot 2015-07-29 14.30.24.png

  • GameObject with Image component:
    2227671--148379--Screenshot 2015-07-29 14.30.59.png

I’ve tried various sprites at differing sizes and qualities for the Mask, all with the same result, but the one in this example is attached. Basically it’s a white square with a transparency, so that we can apply color programmatically. The Text color becomes the color of the textured look, while the Image color appears as the color of the text.

The resulting text with the Mask applied looks terrible, relative to normal text. Antialiasing seems to either not be working at all in this case, or we are missing some kind of setting somewhere.

Before masking:
2227671--148380--text_no_texture.png

After masking:
2227671--148381--text_with_texture.jpg

My questions are:

  • Is this the crazy way of doing it?
  • Is there a possible bug we’re running into?
  • Is there a better way to accomplish the same goal? Maybe using a material (I’ve played with this but couldn’t really figure out how to have the same effect)?

2227671--148382--texture_white_light.png

This is better done with a shader.
Try this one(attached), i took the Uii-Unlit TextDetail shader and changed it to use UV1 instead of 2.
Put your texture into the detail slot.

2228389–148442–TexturedFont.shader (2.12 KB)

2 Likes

Apologies for the delay! I was out of town for a few days and am catching up now.

I’ve tried adding our texture to the Detail slot, using this shader on a new material, but it seems that only the material’s color is applied and not the texture. The Alpha slot was left blank, though I also tried adding the Font Texture from our dynamic font (which produced errors).

I am very new to shaders and their use in materials, so likely I’m just missing something simple here…

Any thoughts on why that shader might not be working? Is it possible the texture’s import settings impact the shader? I’ve tried various settings there but it doesn’t seem to make a difference.

1 Like