guiTexture color half alpha White?

So i have a guiTexture that needs to be half Transparent. Like half see through, but not all the way clear… Any ideas? This is what I have so far in JS…

#pragma strict

static var CanMove = false;
static var ShowGUI = false;
//var Click1Sound: GameObject;

function Start () {

CanMove = true;
ShowGUI = true;

}

function Update () {

if(ShowGUI == true ){


guiTexture.enabled = true;


}else{

guiTexture.enabled = false;

}


if(CanMove == true){

if(Input.touchCount > 0 ){

for(var i : int = 0; i < Input.touchCount; i++){

var touch : Touch = Input.GetTouch(i);

if(touch.phase == TouchPhase.Began &&
guiTexture.HitTest(touch.position)){



CameraCUSTOM_Movement.MoveRight = true;

}
}
}else{

// this makes it all the way clear, but I want it to be half way

guiTexture.color.a = 0;

//////////////////////////////////////////////////////////////////


CameraCUSTOM_Movement.MoveRight = false;

}
}
}

Thanks- :slight_smile:

guiTexture.color.a = 0.5;

I have already tried that and it does not work for some reason..

"does not work" does not help anyone help you.

I have tried guiTexture.color.a = 0.5; and when I play it in the editor it looks the same as it would if it were guiTexture.color.a = 1;. I am not sure if the alpha is just a Int. rather than a float. All I am trying to do is make the GUI half way transparent when it's not being touched, but when I touch it, it is fully view able.

You are talking about a GUITexture? It is working fine for me. Start with a brand new GUITexture. Drop in your texture of choice. Then add this simple script: function Start () { var guitex : GUITexture = GetComponent(GUITexture); guitex.color.a = 0.25; }

1 Answer

1

Oh ok. I didn’t think to use GetComponent… Thanks it’s working! You answered my question like a Boss. Cheers :slight_smile: