- Home /
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- :)
I have already tried that and it does not work for some reason..
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;
}
Answer by Triqy · Mar 22, 2013 at 05:24 AM
Oh ok. I didn't think to use GetComponent... Thanks it's working! You answered my question like a Boss. Cheers :)
Your answer
Follow this Question
Related Questions
Cannot set UnityUI.Image opacity when place on a UnityUI.Button 2 Answers
GUI.DrawTexture on GUI.Button press 1 Answer
(For Loop) Converting Gui Button to GuiText & GuiTexture 1 Answer
Making GUI Buttons on a GUI Texture 1 Answer
How to have correct color on imGUI Buttons (as dynamic textures) avoiding multiply effect ? 1 Answer