1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

ScrollView problems

Discussion in 'Extensions & OnGUI' started by Discord, Feb 25, 2011.

  1. Discord

    Discord

    Joined:
    Mar 19, 2009
    Messages:
    968
    I'm using a ScrollView with a GUILayout and I'm wondering if there is anyway to tell if the user is scrolled all the way to the bottom at any point? I know you can access the y position of the Vector2 you pass to the GUILayout.BeginScrollView() function, but I'm not sure how to determine if the user is scrolled all the way to the bottom of the scroll view.

    Any help is appreciated.
     
  2. Discord

    Discord

    Joined:
    Mar 19, 2009
    Messages:
    968
    Bump. I haven't found a good fix for this.
     
  3. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Messages:
    727
    Looked at this for a little bit, but there's not much you do with the scrollPosition.y because it just tells you the y position of the scrollbar, what you need to know is how much content there is to show in the window, and there's not a variable for that.

    If you knew the content size, then you could deduce the relative position of the scrollbar by using the window height and scrollPosition.y.
     
  4. Daniel-Brauer

    Daniel-Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Messages:
    3,311
    You should be able to get the content height by using GetLastRect() after the last piece of content. Add the y and height components of the Rect and see what you get.
     
  5. Discord

    Discord

    Joined:
    Mar 19, 2009
    Messages:
    968
    Thanks! I will try that. Hopefully the fact that it happens during the repaint event won't affect anything. I'll see how this goes.