Is it possible to draw a texture on the screen but in a different color?
Specifically, in smash bros the Damage Ratio changes from white to red the higher the number is. I was wondering how I could draw the sprite I have for the numbers on the damage % to appear more red, where they should be absolutely red if they are at 200 or higher.
It might not be what you are looking for, but it seems like it’s the text you want coloured.
If not, disregard this.
The element used for the text is GuiText, and it has a “color” variable to do just that.
All you have to do is to put the GuiText where you want, create a new script for it, make a variable for the GameObject it has to take the “damage” data from, and do your colour calculation in the OnGui() function.
Specifically, the calculation could be something like this:
public GameObject Character;
public GuiText DamageGuiText;
public int RedDamageLimit = 200;
public void OnGui(){
//This line is wrong, you need to fetch your damage value
int damage = Character.GetComponent<int>("Damage");
if (damage > RedDamageLimit)
damage = RedDamageLimit;
float nonRed = (RedDamageLimit-damage)/((float)RedDamageLimit);
DamageGuiText.color.g = nonRed;
DamageGuiText.color.b = nonRed;
}
The code is not functional as is (the GetComponent is just wrong), and not complete, and the GuiText might be the GameObject the script will be linked to, so no use in having it also in the variables.
Of course, this is a very crude way, but it should show you one way of getting where you want to go.
No not text, sprites! I have sprites for the numbers and the % sign see: