I’ve been learning Editor scripting for the last few hours and kinda have the hang of it. Right now, I’m trying to make healthbar using a [ProgressBar][1].
I have a health and max health variable is exposed in the inspector, and I can’t seem to figure out how use ProgressBar in a way to make the bar work properly.
I know that ProgressBar’s value has to be between 0 and 1, so I tried some math, but wasn’t successful.
ProgressBar ( (((health.intValue + maxHealth.intValue) / 2) /100.0), "health");
The above code snippet works well when the maxHealth value = 100. So I thought, why not change the “100.0” to maxHealth.inValue?
Well, The bar is filled when health and maxHealth is equal, but if I decrease health, it appears that ProgressBar snaps it’s own value from 1 right to 0, because the bar becomes completely empty.