Must be fairly obvious, but I just can’t see it. So help a guy out ![]()
// Assign new listeners
// objectPrefabsCount = 3
for (int i = 0; i < objectPrefabsCount; i++)
{
Debug.Log("object index = " + i);
objectButtons[i].onClick.AddListener(() => _LE.SpawnObject(_LOC.GetCategoryIndex(), i));
Transform child = objectButtons[i].transform.Find("Icon");
if (child != null)
child.GetComponent<Image>().sprite = _LOC.GetIcon(_LOC.GetCatIndex(), i);
}
Debug for above:
Debug value when I actually click on each of the generated buttons.
Category is correct, object is not:
This part is however displaying the correct images:
Transform child = objectButtons[i].transform.Find("Icon");
if (child != null)
child.GetComponent<Image>().sprite = _LOC.GetIcon(_LOC.GetCatIndex(), i);