Hi, all! I am trying to make a GUI scroll box in a chat box that scrolls ONLY VERTICALLY. I looked up GUI.ScrollView in the reference but I just can't seem to wrap my head around it.
This is the portion of code I grabbed from the page...
This is all fine and dandy, but I have a few questions: A. Why is it that the first two lines (after the comments) are not connected? what do they do? Does it supply a domain and then a box or what? B. when I insert my own values, to fit the chat box, nothing shows up. Why?
asked Dec 22 '11 at 11:02 PM
Ok, it seems you missed some basic syntax rules ;)
The compiler doesn't care for new lines or indent-spaces in the first place (except for single-line comments which are terminated at a new line character). Every script could be written in a single line but that's a total mess to read for humans. That's why we struct our scripts in a way that you can easy read and understand what the script does.
Something like that:
Can also be written like that:
There's absolutely no difference in those two forms. It's just to avoid long single-line commands so you don't have to scroll sideway to view it.
The scrollview itself is quite simple. the first parameter defines the rectangle on the screen where your scrollview should be displayed and at what size. In your example at position (10, 300) and the size is (100, 100).
The "scrollposition" is a variable that stores the current scrollposition.
The content area (viewrect) is your virtual space inside the scrollview. in this area you define your GUI elements (buttons, labels, ...). From this area you only see a fraction since the viewable size on screen is defined with (100, 100).
If you don't want to scroll sideways you should make your content rectangle's width smaller so it can be displayed completely inside the visible area. The height should be big enough (more than the viewable area) so it gets actually scrolled.