I have an inventory panel with a grid layout. I instantiate slots in it. Slot is just an image. I made a prefab called Slot. I am adding the slots to the grid via script. How can I set the image in a script like below?
for (int i=0; i< database.items.Count; i++) {
Texture2D icon = database.items[i].icon);
GameObject newSlot = Instantiate(slot) as GameObject;
newSlot.transform.SetParent(GameObject.FindObjectOfType().gameObject.transform, false);
//newSlot.getComponent = icon
}
↧