Hey guys!
First time asking here, I’m really new to scripting in C#, so this might be an over sight on my end, but I’m trying to change the alpha value of the image on the Button UI element.
So the results I’m trying to achieve is on start up, the Button is semi transparent, and when you mouse over the button, it will become fully opaque, and once the mouse leave, the button is transparent again.
This is the Script I made
private Button button;
public Color color;
void Start()
{
button = GetComponent<Button>();
color.a = .7f;
button.image.color = color;
print ("Start");
}
void OnMouseEnter()
{
color.a = 1f;
button.image.color = color;
print ("highlight");
}
void OnMouseExit()
{
color.a = 0.7f;
button.image.color = color;
print ("Exit");
}
I’ve tried adding both a Box Collider and a Box Collider2D but it still doesn’t print anything on the console when I mouse over. Any help on the subject would be much appreciated!
Sincerely,
Jason