2

I'm quite new to Unity. I'm making GUI on Unity and having trouble with the scroll list. I have a prefab of list item. Besides, I get data of around 100 items from server, saved in a List. Now, if a populated data into the Scroll view as normal, I would have to Instantiate 100 instance of list item prefab for the scroll view and this would dramatically reduced the performance of my app. I read on Internet and know there's a technique to handle that, using Object pooling and catch the event of OnBecameVisible/ OnBecameInvisible of each list item. However, there's actually no any example could explain clearly for me.

Anyone could help me to solve this, especially, when OnBecameVisible is called???

Brian Pham
  • 551
  • 9
  • 23
  • 1
    if you are making a scrollable list with many rows (more than 20) and you have only a few rows visible (10 for example) i would suggest that you only make 10 rows with UI elements. then you add a scrollbar, but you don't use the scrollbar to move the rows. instead you use the scrollbar value to change the content of your 10 rows with the content of your 100 objects. for example: if the scrollbar is on top, you show elements 0-10 from 100 and if it is on the bottom, you show elements 90-100. that way you can fake scrolling and have only 10 row instead of 100. – Jinjinov Jun 16 '15 at 08:24

0 Answers0