1
\$\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\$
  • \$\begingroup\$ Hi what do you need exactly? why do you need masking text? \$\endgroup\$ – Seyed Morteza Kamali Oct 9 at 18:57
  • \$\begingroup\$ I need to mask the number as I'm masking the entire card \$\endgroup\$ – CollisionOfConcepts Oct 9 at 19:34
  • \$\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\$ – Seyed Morteza Kamali Oct 10 at 4:27
  • \$\begingroup\$ So I want everything in the red square to be masked/invisible. i.imgur.com/Jg0b5RF.jpg \$\endgroup\$ – CollisionOfConcepts Oct 10 at 17:46
  • \$\begingroup\$ you should set Stencil buffer to your text to fix this issue \$\endgroup\$ – Seyed Morteza Kamali Oct 12 at 15:03
2
\$\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\$
  • \$\begingroup\$ Thank you for this answer, I have already implemented the sprite solution. \$\endgroup\$ – CollisionOfConcepts Oct 28 at 20:00
  • \$\begingroup\$ @CollisionOfConcepts you're welcome dear friend. \$\endgroup\$ – Seyed Morteza Kamali Oct 28 at 20:21
  • \$\begingroup\$ @CollisionOfConcepts If this solved your problem, and I see that it has, I suggest marking it as such. \$\endgroup\$ – Demetre Saghliani Nov 11 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.