I just typed out this question after hours of trying to figure this out, only to have the website ditch my question when I signed in to complete the post, so you can image I’m pretty frustrated by now.
All I want to do is change the color of my button using JS. I’ve looked at over 50 results on Google, and nothing answers my question.
I’ve tried a ton of different things, some compile and don’t work, others don’t compile at all.
My button is a GameObject Button, and it is a child of a Canvas object. The button is a toggle, and the toggle already works, but I just can’t change the color of the button. I have 2 materials set for the different states of the button, and I want the button to be Yellow when it is active, and White when it is idle. Here’s what I’ve tried:
mybutton.renderer.material = myMaterial; //compiles, does nothing (yes myMaterial is set)
mybutton.renderer.material.color = Color.yellow; //compiles, does nothing
mybutton.image.color = Color.yellow; //does not compile
mybutton.image.color.normalColor = Color.yellow; //does not compile
mybutton.colors.color = Color.yellow; //does not compile
All I want to do is change the color of the default state of the button once. If anyone can tell me how to do that, I’d be grateful. Thanks in advance.