Good day.
There is a button and a window. When you click on a button, the window changes its transparency. How to make the change in the degree of transparency was smooth?
public GameObject AlphaObj; public Image AlphaImage; private int AlphaCheck = 0; void Update() { AlphaImage = AlphaObj.GetComponent<Image>(); } public void OpenClose() { if (AlphaCheck == 0) { AlphaImage.color = new Color(AlphaImage.color.r, AlphaImage.color.g, AlphaImage.color.b, AlphaImage.color.a + 1.0f); AlphaCheck = 1; } else { AlphaImage.color = new Color(AlphaImage.color.r, AlphaImage.color.g, AlphaImage.color.b, AlphaImage.color.a - 1.0f); AlphaCheck = 0; } } As an option, I can push the change of transparency in Update with the addition of Time.deltaTime, and in OpenClose, leave the change in the check value. But perhaps there is an option without overloading such a trifle Update'a.