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 /
avatar image
0
Question by bastianmeyerbm3 · Aug 20, 2018 at 09:38 AM · uieventscrollviewscrollingrefresh

ScrollView/ScrollRect scrolling "refresh" event?

Hi,
i have a question that refers to the possibilities of ScrollViews / Scrollrects in Unity. Is it possible to get a similar result like this ?

I created a ScrollView with the "Movement Type" elastic so this works partly. But is there an event that triggers when i "scroll too far?"

Comment
Add comment
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

1 Reply

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

Answer by FernandoHC · Aug 20, 2018 at 10:14 AM

Yes you can achieve that same result, unfortunately scrollRect is a bit limited in that regard, so what I do is to have 2 objects relative to the top position of the scrollRect panel and one object relative to the top position of the Content panel, then calculate their distance. I then calculate the distance on the event:

scrollRect.onValueChanged.AddListener(OnScrollRectChange);

     private void OnScrollRectChange(Vector2 position)
     {
         if (loading || !enableScrollLoadMore)
             return;
 
         // Detect if more messages should be loaded
         if (loadMoreObjectPosition.transform.position.y < loadMorePivotBottom.transform.position.y - 20)
         {
             Debug.Log("Load more relics");
         }
     }


You could also use the position vector2 param of the event to observe the value of the scrolling and use that, just be careful because that value is relative to the size of the content and will vary depending on it.

Comment
Add comment · Show 4 · 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 bastianmeyerbm3 · Aug 20, 2018 at 10:38 AM 0
Share

Thank you that helped A LOT

avatar image bastianmeyerbm3 · Aug 22, 2018 at 07:07 PM 0
Share

Short question: What is the purpose of this Code-Block? @FernandoHC

  if (loading || !enableScrollLoad$$anonymous$$ore)
      return;

avatar image FernandoHC bastianmeyerbm3 · Aug 23, 2018 at 10:50 AM 0
Share

Because this code is in the same class as the network request call I do to the server, I have the loading = true while the server request is waiting to be completed (takes about a fraction of a second, but we don't want to call the same request again while it is loading).
The enableScrollLoad$$anonymous$$ore is another controller I have in the UI, when I don't want it to load for any other reason, like while the gameobject has not been initialized yet, or if the user is spam$$anonymous$$g, etc.

avatar image bastianmeyerbm3 FernandoHC · Aug 24, 2018 at 04:47 PM 0
Share

Okay i understand that thank you! That sounds reasonable, i will implement it too, great hint.

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

150 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

Related Questions

Moving a ScrollRect child via script to focus on some point. 0 Answers

How can I programmatically tween a Scroll View to a desired position? 0 Answers

Scroll View: Is there a way to discriminate and accept only certain PointerEvents? 0 Answers

Scaling scroll view width to its content width or vice versa 0 Answers

Scrollbar touch sensitivity 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