I have a JSON file that contains names and image urls.
Ive managed to put together a script that can display a single image based on a unique word entered in an input box.
Search for “Test1” and the rawimage texture is the jpeg url linked to that entry in the json file.
There are going to be some searches that will show multiple results and i am trying to find a way to display all of the results as a scrolling menu, or if thats not possible have a next button appear if more than 1 pages amount of maximum results is found, maybe 3 per page.
As i dont know the number of results that will be returned how will i display numerous images in my UI that match the search term.
These images also need to be clickable and that image carried over to the next scene, but thats an issue for another day
I don’t see the problem here? You already pretty much answered your own questions.
It’s definitely possible to create a menu with scrolling items. It’s also possible you create paginated item lists with next button to go to the next “page” until you exhaust the list of items.
And how come you don’t know the amount of items? When your query to database/web or where ever your JSON comes from is finished, I’m sure you will have the data in your hands. So calculate the number of items, and then use code to create the required UI components or adjust existing templates you have on your Canvas.
And you can handle your clickability the same way; when you have your query results, create the required functionality to the images UI presentation. If you need to save the images, maybe use EncodeToPNG and then BinaryWriter to write to the disk/device storage.
The json file will contains hundreds of image urls and obviously the number of items shown will depend on the search term, so it could bring up 2 items, it could bring up 50 depending on how vague their search is.
I was wondering how I can generate images/objects, based on the results, because obviously I don’t want to make 500 objects and then hide the ones that aren’t in use, I was hoping there’d be a way to automatically have the script create the amount of objects needed to fulfill the search results.
And then how to best display them. Like have a scroll that expands depending on how many items it has.