EDIT: attempting to state my question more clearly
In my game the mouse scrollwheel zooms the camera in and out.
I have a GUILayout.Label on the screen that is inside a scrollview.
The code looks something like this:
If textOfArbitraryLength is long enough (such that it is taller than someRectangle and requires a vertical slider) I would like for mouse scrollwheel input to control the scrolling of the text.
If textOfArbitraryLength is small enough (such that it fits inside of someRectangle without scrolling) I would like for mouse scrollwheel input to control the zooming of the camera.
Is it possible to determine if there is a slider present in the scrollview?
I want to be able to determine when the Camera Control script should ignore scrollwheel input.
Sorry if I did a bad job explaining what I was looking for... And thanks in advance for any help.
Is it possible to determine whether or not a slider is being used inside a scrollview when using GUILayout?
I have a label inside a scrollview and would like to ignore input from the mouse scrollwheel when the mouse is over the label AND the content is scrollable. In other words, I don't want undesired things to happen in the scene when the user is trying to scroll over the text in the label.
If the content of the label fits within the scrollview (ie there is no slider) I would like to process mouse input as usual. Most of the time this is the case...
I can almost accomplish this by checking to see if the scrollPosition vector's y-value is 0, but not quite. If the user scrolls up too much, there will be undesired effects once the slider hits the top and the scroll wheel keeps moving.
Thanks in advance for any help...
Just don't assign the returned value to your scrollposition in that case...
Just to complete the example. Here in C#:
As you said you want the opposite. You want to know when the users mouse cursor is over a scrollview. With GUILayoutUtility.GetLastRect you can query the last layouted rectangle. But that only returns the right Rect in the repaint event, not during the layouting step.
Another way could be using the tooltip functionality, but unfortunately a scrollview doesn't have a tooltip...
I think it should be possible to do that for arbitrary content by using GetLastRect on a grouping control inside the scrollview to determine its size. But again, not tested.