Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Masking Text?

A topic by AnthonyUccello created Aug 22, 2020 Views: 1,870 Replies: 8
Viewing posts 1 to 7
(1 edit)

Hello

We have an issue where we need to mask the text when its moved under a mask. Can you suggest how this can be done?

For sprites we just set the mask interaction enabled but we are not sure what to do with a SuperTextMesh object.

Developer

Hmm... with regular sprites, I don't believe the shader supports this, but if you're using Unity UI, masking should work! (Try messing with the values exposed on your text material in the material's inspector!)

I can look into seeing what it'd take to allow masking support on the shader exactly, iirc it's something to do with the stencil buffer...?

I have almost no knowledge of shaders. What makes it even more complicated is masking needs to be turned on and off so I guess I need 2 shaders for this? One with masking one without?

We have cards which have text and they are inside a scrollview. The parent has a sprite mask and it works for the images but not the text. I tried having both a SpriteMask and a Mask but that didnt work. If I have JUST a mask it does seem to mask the text but given that we need this to work with a SpriteMask (or in addition to a Sprite Mask) I am currently confused as what a next step could be...

Developer

When you say scrollview, do you mean a Unity UI scroll view? If so... check out the "UITest" sample scene to see some masking examples. (It's a bit messy, I know...)

If it's Unity UI, I believe just the parent object needs a Mask attached to it. Then, on the Super Text Mesh object, you can change the Mask Mode from "Inside" to "Outside". The order of objects in the hierarchy plays into masking!

If it's not Unity UI... I'll look into this a bit more! So just lemme know!

The issue we were having is we have a sprite mask and it didnt seem to work with the mask. However we used this Stencil buffer setting and it seems to have worked: https://gamedev.stackexchange.com/questions/176170/how-to-use-a-sprite-mask-or-shader-to-mask-a-text 

I have absolutely no idea what this does or why it works. But it seems to for now...

I'm having a similar issue. Where did you find that stencil buffer setting? I can't seem to find it anywhere, nor see it in any Unity documentation.

Developer (1 edit)

Find the material that the STM object is using in the project folder, then view it's inspector. The stencil buffer settings are exposed there! You might have to change STM's text to force the material to update.

Developer

I'm really confused, since mixing UI elements and non-UI elements can have strange results... but if it works, it works!