Sprite prefab with GUI text

Hello and thank you having a look!

I am making a game based on the 2D Roguelike tutorial ( 2D Roguelike - Unity Learn ), so I have prefabs that are spawned randomly, and the movement is grid based.

I would like to display a variable on a sprite (see attachment).
I need to access the number display, and it should move with the sprite itself.

I am a bit confused as it looks more complicated than I thought it would be.

The way I was thinking of doing is:

  • Have a child GUI Text displaying the variable
  • Have the anchor point and the font size depending on the screen size so it scales corectly.

Is that the best way?
It really feels like it’s not so I’m asking!
Thanks a lot!

2255301--150754--exSpriteGUI.png

bump~

You could add a Unity UI world space canvas to your sprite, and add a Text element to that canvas.