How would you load hundreds of clickable images?
So I've just focused on my gameplay coding to avoid this one, but it's soon time to do it.
What I want to do is have around 200 clickable images load to the screen. I was considering using IMGUI to loop through it, but I don't know how to operate it that well. Namely if I used an OnGUI script on a panel, would it only write the new gui on that panel? Also how would I get the OnGUI to go away?
If you don't suggest OnGUI: How would you do it? Could it even be possibly easier to just go through and add all 200 manually on a scroll rect?
Answer by Dext · May 22, 2016 at 11:25 AM
You should no longer consider the legacy GUI to be a "thing". Its performance is really worse, especially on mobile devices.
Just Set up a Panel and create an Button-UI-child object. Save it as a prefab and instantiate it as a child of the panel when needed. If you need 200 of them, just use a for loop.
It can also appear to be helpful, if you combine this technique with layout groups. So the instantiated childs order correctly horizontal or vertical (just as you have set it up).