Before updating to Windows 10 you may need to return your Pro license. More information here

GUIScrollView: How to set the size of the "client rect"?

I'm currently doing the following:

scrollPosition = GUI.BeginScrollView( new Rect(0,0,25,100), scrollPosition, new Rect(0,0,100,100) ); GUI.EndScrollView();

As you can see, the height of the scroll view is the same as the view rect. In my mind, this should not generate a vertical scroll bar. However, because the horizontal scroll bar is generated (it takes up vertical space), it then results in the vertical scroll bar appearing. Hence, I need a way to get the height of the horizontal scroll bar so I can add it onto the height of the scroll view to compensate. In Windows lingo, this would be the same as setting the "client rect" size of the scroll view. Is there any way of doing this?

more ▼

asked Apr 06, 2010 at 07:04 PM

avatar image

Robert 1
389 47 38 60

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I encountered exactly this issue, and I kind of agree with Cyclops (hard-coding values is not great but in this case I would), though I would make a public member variable so the designer can tweak those Rects and the spacing later if the skin/style changes.

Also you can get the height of the Horizontal Scroll Bar style (e.g. skin.GetStyle("horizontalscrollbar").fixedHeight), though with padding/margins that could probably be changed.

more ▼

answered Apr 12, 2010 at 08:44 PM

avatar image

5.7k 41 62 114

(comments are locked)
10|3000 characters needed characters left

I think the viewRect is basically a "client rect". Personally, I would just subtract 20 from the viewRect height, and call it a day :) I realize hard-coding numbers is frowned upon, but how many times is a scrollbar's dimensions likely to change? (Okay, maybe 20 isn't right, play around with it).

more ▼

answered Apr 06, 2010 at 07:33 PM

avatar image

8.6k 82 112 197

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Apr 06, 2010 at 07:04 PM

Seen: 2355 times

Last Updated: Apr 06, 2010 at 07:04 PM