4
\$\begingroup\$

I'd like to know what I need to learn to apply a shader to achieve masking on the text.

Here is my text object in-game, I'm using a sprite mask to mask the game objects on the card, they're all in their own sorting layer, the order number is 11.

Here is my text in the inspector enter image description here

However, everything on the card is being masked except the text.

a

enter image description here

If someone could tell me what I need to learn to solve this problem that'd be great, can this problem be solved using a shader?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Hi what do you need exactly? why do you need masking text? \$\endgroup\$ Oct 9, 2019 at 18:57
  • 1
    \$\begingroup\$ I need to mask the number as I'm masking the entire card \$\endgroup\$ Oct 9, 2019 at 19:34
  • 1
    \$\begingroup\$ can you make what you need in paint or photoshop and attach to your question? because I didn't understand from your attached Image.half your card rendered! \$\endgroup\$ Oct 10, 2019 at 4:27
  • 1
    \$\begingroup\$ So I want everything in the red square to be masked/invisible. i.imgur.com/Jg0b5RF.jpg \$\endgroup\$ Oct 10, 2019 at 17:46
  • 1
    \$\begingroup\$ you should set Stencil buffer to your text to fix this issue \$\endgroup\$ Oct 12, 2019 at 15:03

1 Answer 1

4
\$\begingroup\$

If your cards are sprite you should use TextMesh because Text Component made for UI Elements.

Sprite Solution

Create a world space Canvas and child it to card sprite.

enter image description here

Use Sprite Mask

enter image description here

Select Visible Inside Mask

enter image description here

Change the Stencil buffer to cut the text

enter image description here

Enjoy!

enter image description here


UI Solution

your game is a card game so you should use UI Elements Instead.

you can mask your Items in UI by Mask Component.

Create a canvas

enter image description here

Add Mask

enter image description here

Child them into mask

enter image description here

also, you can use SoftMaskForUGUI to have a better result

\$\endgroup\$
3
  • \$\begingroup\$ Thank you for this answer, I have already implemented the sprite solution. \$\endgroup\$ Oct 28, 2019 at 20:00
  • \$\begingroup\$ @CollisionOfConcepts you're welcome dear friend. \$\endgroup\$ Oct 28, 2019 at 20:21
  • \$\begingroup\$ @CollisionOfConcepts If this solved your problem, and I see that it has, I suggest marking it as such. \$\endgroup\$ Nov 11, 2019 at 22:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .