I am instantiating a button as a child of a rect transform with the scrolling thing(very good explanation, go me).
When I instantiate the button I am getting the text component of the child to change the text.
I wanted to do the same thing for the color, find the image component of the button and change the color, but the problem is that the color isn’t changing. I even tried to change it at runtime but it doesn’t change even then.
Here is a sample code from my script:
Button playerButton = (Button)Instantiate(buttonPrefab, buttonsParent); Text playerButtonText = playerButton.GetComponentInChildren<Text>(); Image playerButtonImage = playerButton.GetComponent<Image>(); playerButtonText.text = player.playerName; playerButtonImage.color = player.color;