Change texture alpha value on runtime

Hey there!

So, In the GUI I’m currently working on, I need to know if there’s a way to change the texture alpha value during runtime… Actually right now I’ve this:

function OnGUI() {
//some unrelated stuff here

//Hull Background
		GUI.DrawTexture(Rect(Health.hull_area.x, Health.hull_area.y, Health.hull_area.width, Health.hull_area.height), Health.hull_bg);
		
		
		//Hull Foreground
		GUI.DrawTexture(Rect(Health.hull_fg_area.x, Health.hull_fg_area.y, Health.hull_fg_area.width, Health.hull_fg_area.height), Health.hull_fg);
		

//more unrelated stuff


}

Where inside the Health class I’ve the hull_bg and the hull_fg Textures. Is there anyway to make it transparent as the player takes damage, in order to gradually leave the background visible?

Thanks in advance.

JPB18

private Color guiColor;

void Start(){
guiColor = Color.white;
}

void Update(){
guiColor.a = 0.5f;  //a can be from 0 to 1 only, so set it how do you want it to drop down, if you get hit. For now its constant 0.5

//like if lets say your health is 100, you could do 

float alphaLevel = Health/1000;
//and then
guiColor.a = alphaLevel;
}

function OnGUI() {
GUI.color = guiColor; //sets all next gui color to transparetn 0,5

GUI.DrawTexture(Rect(Health.hull_area.x, Health.hull_area.y, Health.hull_area.width, Health.hull_area.height), Health.hull_bg);

GUI.color = Color.white; //sets it back
}