Making a list of images within a scrollrect generated from prefabs tappable/clickable
Right then. Hello!
I've got a container with a dynamic number of elements contained in a scrollrect. I lifted the code from here as a starter: http://www.folio3.com/blog/creating-dynamic-scrollable-lists-with-new-unity-canvas-ui/ (the code is actually a little broken, but it set me in the right direction).
For those who don't want to click, it's a panel containing an image and two text boxes, sitting inside a panel as a prefab, which is replicated into a parent container with the scroll rect stuff set up.
Then I added some stuff which pings a server, downloads the latest list of available assets, generates all the necessary data, and displays them. So far, so good. The things downloads new content, caches it, scrolls perfectly.
I am at my wit's end, now, though trying to work out how to make each element tappable (or clickable, or whatever). I figure I need to add a listener to set up the onclick event, but I don't entirely understand which element to hook it to, or indeed what I need to do to do that. At a stretch, I could change the image into a button, and just use that, but ideally, I'd like the entire prefab to be clickable, and that's just a panel. How would I add an onclick event to that parent panel? Is it even possible?
Thank you in advance.
Answer by zingfharn · Feb 24, 2016 at 01:22 PM
I ended up just turning the image into a button, and making that tappable. Couldn't find any other way. :/
Your answer
Follow this Question
Related Questions
Android detection not detected by android phone 0 Answers
Scrolling as Shown in This Video 0 Answers
How to make a system in unity 0 Answers
PlayerPrefs not debugging 1 Answer
My method is being repeated several times during a single input. 1 Answer