Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ElaxomoeR · Sep 26, 2018 at 05:31 AM · scrollscrolling

Scroll Rect: how to detect if the scroll reach to the end of the list

How can I know exactly when the scrolling reach to its both ends? I am using a horizontal scroll and I though I can give a trigger depend on the scroll content's position but it was not work out. Can anyone help me??

I tried call this from Scroll Rect On Value Change and On Drag End. But does not work.

 public void OnDragScroll()
     {
         if (scrollRect.horizontalNormalizedPosition.Equals(0.0f))
         {
             leftArrowOverLay.SetActive(false);
         }
         else
         {
             leftArrowOverLay.SetActive(true);
         }
         if(scrollRect.horizontalNormalizedPosition.Equals(1.0f))
         {
             rightArrowOverLay.SetActive(false);
         }
         else
         {
             rightArrowOverLay.SetActive(true);
         }
     }
Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image eses · Sep 26, 2018 at 09:04 AM 0
Share

Hi @ElaxomoeR

Your question is bit vague - what do you mean by "when the scrolling reach to its both ends?" - Do you mean that you want something to happen, when user scrolls to either end of some list?

Also, what did you actually try? Show the code what didn't work maybe?

Did you also check the manual? ScrollRect has many methods and values that you could use. For example, verticalNormalizedPosition. This could be used to detect if you are at either end, combine this with it's velocity property, end drag etc?

So - someone could possibly help you, if you just explain what you have already done and what didn't work.

Also, using question heading "Scroll Rect Things ......." - what does "things" tell and why the dots?

avatar image ElaxomoeR eses · Sep 26, 2018 at 10:44 AM 0
Share

Sorry about the title. I just getting annoying on the scroll rect and wrote it down without any purpose. And, yes I want to happen something if the scroll reach either end of the list. Yap, also tried the verticalNormalizedPosition. When I use that, it does not give exact answer. It is keep changing 1 and 0. I updated the question :)

avatar image Rukmani1 · Jan 02, 2020 at 07:43 AM 0
Share

What is leftArrowOverLay and rightArrowOverLay mean?Am new to the unity.,What does the leftArrowOverLay and rightArrowOverLay? Am very new to unity. If my question looks very stupid pardon me. @eses

avatar image Hellium Rukmani1 · Jan 02, 2020 at 09:48 AM 0
Share

They are just variables referencing GameObjects. ElaxomoeR wanted to enable/disable the arrows according to the position of the scrollbar, but you can run the code you want in the conditions.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by eses · Sep 26, 2018 at 12:02 PM

Hi @ElaxomoeR

Don't expect the value of ScrollRect to be exactly something, ScrollRect might stop scrolling, and it's value might be 0.01... or 0.98 for example.

So the position won't equal something, it's either less or more than something.

So try this to check if your Scroll Rect is at the end part of scrolling:

 if (scrollRect.verticalNormalizedPosition >= 0.95f) // scrolled near end


And to check beginning part of Scroll Rect:

 else  if (scrollRect.verticalNormalizedPosition <= 0.05f) // scrolled near start


I think you should definitely call it from ScrollRect.onValueChanged listener, as dragging might end way before scrolling of content stops... I think.

"Yap, also tried the verticalNormalizedPosition. When I use that, it does not give exact answer. It is keep changing 1 and 0. "

It's a float value, and it goes from 0-1.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ElaxomoeR · Sep 27, 2018 at 03:55 AM 1
Share

Thank you! It works perfectly now.

 if (scrollRect.horizontalNormalizedPosition <= 0.05f)
         {
             leftArrowOverLay.SetActive(false);
         }
         else
         {
             leftArrowOverLay.SetActive(true);
         }
         if(scrollRect.horizontalNormalizedPosition >= 0.95f)
         {
             rightArrowOverLay.SetActive(false);
         }
         else
         {
             rightArrowOverLay.SetActive(true);
         }

By calling it from onValueChanged listener.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

152 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scroll lag to much 0 Answers

Speed up Scroll Rect drag 0 Answers

Scroll Rect doesn't work when you have UI with click events on them. 0 Answers

How to make a scroll rect NOT overflow? 1 Answer

Scroll list isn't working,Scroll list not scrolling. Can someone help me? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges