- Home /
Help with GUI, Textures and Materials (Health Circle)
Hello everyone!
SO, I'm doing this project where I need to make a circular health bar with two textures:
Circular gradient from green to red;
Blue background (also circular);
So, I've this value (curHealth), stored in another script (PlayerHealth), and along with other value (maxHealth), will control the bar/circle. So here we have:
PlayerHealth.curHealth;
PlayerHealth.maxHealth;
And I've this script, written with help of the "LifeBar" tutorial:
HPTexture.SetFloat("_Cutoff", Mathf.InverseLerp(0, maxHealth, curHealth));
GUI.DrawTexture(new Rect(HPPositionH, HPPositionV, HPWidth, HPHeight), HPTexture);
GUI.DrawTexture(new Rect(HPPositionH, HPPositionV, HPWidth, HPHeight), HPbackground);
The above snippet is inside the OnGUI function, alongside with other GUI textures and a label, and the variable creation is all made outside the functions.
So, what's the issue with this script and why doesn't my health circle show up?
I'd appreciate that someone showed me how to do this the scripting way/fix this. Also I'm using Unity Free and UnityScript.
Thank you in advance!