Home > Back-end >  How do I attach a text component to a 2D sprite?
How do I attach a text component to a 2D sprite?

Time:08-11

My game has this system where the player is rewarded with hearts.

Whenever a heart appears, it's supposed to appear with a value on it (say, 5). I did some googling and everything said I need to attach a canvas to the sprite and then a text component to the canvas. However, this doesn't seem to do anything.

CodePudding user response:

You just need the following structure

enter image description here

Sample Image settings: (Here you'll want to replace the "Source Image" with your heart sprite)

enter image description here

Sample Text settings: (Although I recommend using the TextMeshPro component instead)

enter image description here

Result:

enter image description here

  • Related