Skip to main content
Source Link
nachime
  • 261
  • 1
  • 3
  • 4

How to create gui image with script

So I've been fiddling around with the new UI system recently -- and one problem I have is adding images of my sprites to the ui.

I know I can create a prefab of an image gameobject with the sprite I want, but I have hundreds of the sprites I want to add to the ui (They're different characters) so I don't want to create hundreds of prefabs. Instead, what I want to do is in a script, create an image gameobject, set its sprite, and child it to a parent panel in my canvas. Is this possible?