I am making an FPS game in which when you are near an item a UI Text appears at the bottom center of the screen indicating the name of the item and the button to pick it up (let's say [E]).
It works fine but since I couldn't get a clear contrast between the text and the game area (like if the player's standing in front of an egg and the color of the text is white, you can't see the text), I decided to add a black background image to the text.
Now since the item names are of different lengths, I need the image length to match the text length. The background image should just be enough to fit the text How can I go about doing this? Or is there a better way to show a message to the player?