I have a button with the following setup that i am using in a dynamic scroll list:
[43457-skarmavbild-2015-03-28-kl-164741.png*_|43457]
I have added the image component to get the following look to the button:
[43458-skarmavbild-2015-03-28-kl-164908.png*_|43458]
Depending on the number of players i want to change the image, the one added on the left, but i am just not get it how to do access the sprite.
I know that i should use GetComponent or GetComponentInChildren but i just can’t get it to work. I have tried quite a few different options. I am able to access the text, as cane seen in the code below. The way i initiate the button, in a dynamic scroll list, is the following:
//create a new item, name it, and set the parent
Button newItem = Instantiate(btn_Template) as Button;
newItem.name = theActiveTemplates*;*
newItem.transform.SetParent(gameObject.transform, false);
newItem.GetComponentInChildren().text = theActiveTemplates*;*
…
_*
_*