Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Instantiate a prefab in a scrollview only if visible

Discussion in '2D' started by bocilef906, Sep 24, 2020.

  1. bocilef906

    bocilef906

    Joined:
    Sep 24, 2020
    Posts:
    4
    Hello, like the title says I'm currently trying to find a updated a free way to instantiate a prefab when scrolling a scrollview. I have a menu with like 100 items and instantiate 100 of them is really heavy and laggy so I was wondering how to instantiate like 10 objects and reuse them while scrolling up/down

    Thanks.
     
  2. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    Wrong Forum to ask. You want to ask the UI forum for this sort of thing. My guess is you'll need custom version of the scroll view, but that's only a guess.
     
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @bocilef906

    Wrong forum like already said.

    Did you actually check asset store? IIRC there are free solutions for scrollrect that recycle items.

    It is not trivial to do IMO so try those first (I've created such script once, had all kinds of issues)?
     
  4. bocilef906

    bocilef906

    Joined:
    Sep 24, 2020
    Posts:
    4
    I just don't want to mess the script by adding/removing stuff, the script I made changes texts and images when populating the canvas