Quantcast
Channel: Questions in topic: "dynamically"
Viewing all articles
Browse latest Browse all 152

How to set prefab images from script?

$
0
0
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 }

Viewing all articles
Browse latest Browse all 152

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>