I’m working on a 2D strategy game, and I’d like to use generic square sprites and then overlay them with stats that change dynamically – e.g., attack strength, movement, health.
I tried adding a simple Text component, but I couldn’t get that to display at all. I also tried adding a Panel, then an Image, then a TMP or text object, but I had trouble getting it to display anything, and it seemed like overkill for what I want to do.
Then I tried a TextMeshPro component, using a sprite asset that I put in the Resources/Sprite Assets folder. (I found a helpful 45-minute video on this.) I successfully made a sprite asset, just using my one sprite for now. (I do have many variants I’d like to use, and I guess I’ll have to make a sprite sheet or such for that, but that’s a problem for another day.) I typed in the code <sprite=“Infantry” name=“Infantry”> and then, immediately aftewards or on the next line, “6-3,” (some sample stats). That does display the sprite and text both, but it displays the text next to the image, not overlapping it. In Scene mode, I can sorta get the text to overlap the sprite by setting the text’s sorting layer. But in game mode, it seems to revert: the sprite appears, then the text below it, with no overlap.
What’s more, if I change the text font, the sprite resizes too, which is not what I want. Note that the 6-3 is a lot larger than the space I want to put it in, at the bottom of the counter.
Maybe I should try a Button instead? I don’t really need Button functionality, but they look right – a background sprite with foreground text. Another option is just to create a sprite for every conceivable strength/movement combination, but that doesn’t really suit this project. (That might work in a game where every unit is unique, but that’s not the case with mine; plus I need dynamic stats.)
I apologize if this seems like an embarrassingly simple question, but I’ve spent a couple hours reading the documentation and Googling, and I’m still stumped. Thanks in advance for any suggestions.