- Home /
alpha value not changing(gradual decrease) during runtime
hi ..is that possible to decrease the alpha value during run time..this is the code i have used for decreasing alpha value bt itz not at all changing,bt red ,green,blue values are changing during runtime. i want to change the alpha value form 0 to 255 or vice versa during runtime.below is the code i used.thanks in advance.help needed
void Start () {
color color = renderer.material.color;
colortemp = 255;
}
void Update () {
colortemp -= 1f;
color.a = colortemp;
renderer.material.color = new Color(255,255,255,colortemp);
}
if i replace 255 with colortemp ,its is changing during run time.but,the alpha value is not changing during runtime. thanks in advance
Answer by Wolfram · Jan 11, 2013 at 01:09 PM
The Color class expects all parameters to be between 0..1, not 0..255.
Note you can use Color32 instead.
thanks a lot Wolfram $$anonymous$$resse. it helped me a lot..prob is that the value for the alpha is showing from 1 to 255 and so on in the inspector..but when it comes to the case of changing the alpha value through code,it has to be varied from 0 to 1...not form 0 to 255 and so on..thanks to unity and thanks to unity forum