Hey guys I can’t figure out why the alpha value of the object wont increase/decrease. I had another example in a different script that worked fine. Now I’m trying a similar version with a script attached to the object itself. (fade and buttonDone are both set to false in start function). Please take a look. Update block;
//Fade out the button.
if(fade == true && buttonDone){
var RGBA = this.renderer.material.color;
var valA = this.renderer.material.color.a;
var valR = this.renderer.material.color.r;
var valG = this.renderer.material.color.g;
var valB = this.renderer.material.color.b;
if(valA > 0){
valA -= .035f;
RGBA= new Color(valR, valG, valB, valA);
if(valA <= 0){
valA = 0;
buttonDone = false;
fade = false;
Destroy(this);
}
}
}
//Fade in the button.
if(fade == false && !buttonDone){
var valA = this.renderer.material.color.a;
var RGBA = this.renderer.material.color;
var valR = this.renderer.material.color.r;
var valG = this.renderer.material.color.g;
var valB = this.renderer.material.color.b;
Debug.Log(RGBA + " alpha: " + valA);
if(valA < 1.0f){
valA += .035f;
RGBA = new Color(valR, valG, valB, valA);
if(valA >= 1.0f){
valA = 1.0f;
buttonDone = true;
}
}
}