- Home /
Question by
unity_82tI_s_-wuwDSA · Nov 25, 2019 at 07:17 PM ·
coloralpha-channel
Alpha component not changing
I need to make button transparet, after animation starts, so i have this code:
public class ButtonTurnVisible : StateMachineBehaviour
{
public Button but;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (but == null)
but = animator.gameObject.GetComponent<FieldLinkForAnimator>().but;
ColorBlock cb = but.colors;
Color newColor = cb.normalColor;
Debug.Log(("Нормальный цвет - ",cb.normalColor));
newColor.a = 0;
cb.normalColor = newColor;
Debug.Log(cb.normalColor);
but.colors = cb;
Debug.Log(but.colors.normalColor);
Color transparence = but.GetComponentInChildren<Text>().color;
transparence.a = 0;
but.GetComponentInChildren<Text>().color = transparence;
}
}
The problem is - alpha doesnt change, as u can see in screenshot. I mean, debug.log tells that everythings fine, but button alpha still 1. Moreover, if i change newColor.a to newColor.b (or any orher, red or green), function works, and black button turns into blue. Whats wrong?
question.png
(28.2 kB)
Comment
Your answer
Follow this Question
Related Questions
alpha value not changing(gradual decrease) during runtime 1 Answer
Alpha channel imported from photoshop problem 0 Answers
Unity panel with border radius and a solid color 1 Answer
Problem Changin Standard shader Alpha Channel 0 Answers
Removing rgb channels from material animation turns color black 1 Answer