For example, there are two buttons and when you click on one of them you need to change the color of both: one is “right” and the other is “wrong”. Initially, I change the color through OnMouseButton , but this method only works on the button that was clicked. And how to change the color on another button at the same time?
|
1 answer
Connect the buttons to each other (for example, add the "public GameObject secondButton" property to each, and add buttons to each other in the inspector), then change the color in OnMouseButton to not only "yourself", but also to the linked "neighbor".
If in mind, instead of the "second button" property, it is better to combine the buttons with some tag, and in the handler just change the color of all the buttons with this tag so that you can add more than two buttons to the group without rewriting the code. .. but this is already in the mind, for a start do it in a simple way :)
|