UI Button Doesn't Render [C#]
Hi iI have a shop based on UI Buttons. When I have bought an item it should change the sprite and colour of the button, but it doesn't render when i buy it, so basically it looks like when you buy the colour it disappears. CODE:
private void InitShop()
{
int i = 0;
foreach (Transform t in colorPanel)
{
int currentIndex = i;
Button b = t.GetComponent<Button> ();
b.onClick.AddListener (() => OnColorSelect(currentIndex));
Image img = t.GetComponent<Image>();
if (SaveManager.Instance.IsColorOwned(currentIndex) == false)
{
img.sprite = notowned;
img.color = new Color(255, 255, 255);
}
else
{
img.sprite = owned;
img.color = Manager.Instance.playerColors[activeColorIndex];
}
i++;
}
i = 0;
}
screenprint2.png
(93.1 kB)
screenprint1.png
(130.6 kB)
Comment
Your answer
Follow this Question
Related Questions
How to change a button image with script? 1 Answer
UI button class 1 Answer
Unity UI Problem 0 Answers
UI Shop Query 0 Answers
UI image component problems with Character Creation.... 0 Answers