- Home /
Replacing letters with images?
Hello everyone! I've been working on a Doom clone for a class project for the past few days, however it cant seem to get the text styling just right (Been looking around and it seems theres nothing to be done about that.
So i was wondering if its possible to replace a letter with a image?
The letters i want replaced is a GUIText object that displays the users health. However i cant seem to figure out how to 'add' in pictures. I'm guessing I'm going to have to use GUITexture instead, but a GUITexture can only hold one image at a time? (I think), so I'm stuck with not being able to display anything more then the first image (Like the image that displays a "1").
Of course i have not tried this yet, I'm going to try it out after this has been posted. But in case i cant get it working I've put this up.
Hopefully someone can help.
I kinda don't get what you are trying to do. Are you trying to ad an icon for the health? In this case I would suggest to use a GUITexture for the icon and a GUIText next to it for the actuall number. If you want to change the appearance of your letters then you should use a different font. There is even a doom like font available http://www.dafont.com/amazdoom.font . The lisence is Creative Commons Attribution-Noncommercial this should fit for a class project.
The problem is that its not actually completely like the real Doom font, the % looks different, and other then that i need the style of the text. I'm trying to make it so that if the player has 100 health, the 2 images "1.png, 0.png" will replace them. So that the 1 will be replaced with "1.png" and the 0'es will be replaced by "0.png". I've found a way to do this though, by having 4 GUITextures and then making 100 If's i can get what i want.. However that is just stupid =/ Was hoping there was a way that woulden take up 300-400 lines of code.
Answer by Eric5h5 · Sep 16, 2012 at 12:18 AM
Use a bitmapped font with GUIText, then it can look like whatever you want. (It must be a GUIText object, since only TrueType fonts work with OnGUI code.) See SaveFontTexture if you want to modify an existing TTF.
Awesome! Will check it out! I just spent 30$$anonymous$$ progrma$$anonymous$$g 500 lines of "If this and that then do this" xD
You could probably reduce that to 5 lines of code by using arrays, but nevertheless, using GUIText is more convenient.
Just refused to work. Unfortunantly i dont have the time to mess about with it. I've made the 100 if sentences and I'll stick to that for now. Thank you for the help.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to Show / Hide a GUI Texture 1 Answer
generate GUIText at runtime C# 3 Answers
Why is my OnCollisonEnter not working? 1 Answer
A node in a childnode? 1 Answer