Search code examples
c#unity-game-enginescrollscrollrect

How to detect if a scrollrect is close to reach its bottom?


everyone! I'm making a scrollable list and want to simple add more elements to it when it is reaching its bottom. Basically an infinite list with content being added to it "on demand". I've tried to get the scrollrect's verticalNormalizedPosition and when it reaches a certain value close to zero, I would call a method to add more items to the list, but it didn't work. How can I do this? (Also, I couldn't find here a similar post). Thanks for the attention in advance.


Solution

  • Scroll rect has a normalized position:

    https://docs.unity3d.com/ScriptReference/UI.ScrollRect-normalizedPosition.html

    So as you get closer to 1, you are reaching the end of it.