Maybe a basic question, but I couldn't find an answer on google.
I'm making a healthbar in Unity C#, and I'm using Graphics.DrawTexture to display the healthbar, but for some reason the texture is blending with the background. The material uses the 'Transparent/Cutout/Diffuse' shader.
Here's the code:
public class Interface : MonoBehaviour
{
public Texture2D healthBarTex;
public Material healthBarMat;
public float hitPoints;
private GameObject player;
void Awake()
{
player = GameObject.Find("Player");
}
void OnGUI()
{
hitPoints = player.GetComponent<Health>().hitPoints;
if (Event.current.type.Equals(EventType.Repaint))
{
Graphics.DrawTexture(new Rect(0, 25, 500, 100), healthBarTex, healthBarMat);
healthBarMat.SetFloat("_Cutoff", 1 - (hitPoints / 100));
}
}
}
And a screenshot: