我想逐漸改變我的UI圖像的alpha,而不是立即。到目前爲止,我對我的褪色圖像的Alpha代碼即刻如下隨着時間的推移統一褪色圖像alpha
public void Highlight()
{
foreach (Image image in imagesToHighlight)
{
Color c = image.color;
if(c.a < maxColor)
{
c.a = maxColor;
}
image.color = c;
}
foreach (Image image in imagesToFade)
{
Color c = image.color;
if(c.a > halfColor)
{
c.a = halfColor;
}
image.color = c;
}
}
上面的代碼工作正常,但我掙扎修改我的代碼,這樣,而不是立即這樣做,但它確實是在緩慢一秒鐘或兩秒鐘。我嘗試將c.a = maxColor;
更改爲c.a--
,以查看圖像是否會持續淡出,但alpha會立即下降。
我在做什麼錯?
感謝您的幫助,我並不想修改它,如果圖像褪色,它可以回到充滿色彩。我怎麼能這樣做? – N0xus
更新了答案 –