- Home /
Scrollview is positioning things incorrectly
Greetings; I'm trying to implement a vertically-scrolling GUI area containing a list of "items," but there are a few problems with it that I can't seem to fix after 1-to-2 hours of tinkering. First and foremost, when I drag the scrollbar for a list of items down, the items at the top seem to "move out" of the scrollbar area. There's also a pesky horizontal scrollbar at the bottom that I can't interact with that shouldn't be there, and the box seems to be drawing at 0,0, as opposed to the 10,10 that I want it to be drawn at. To illustrate the problem:
Relevant code:
void Menu()
{
GUILayout.BeginArea(new Rect(10, 10, width, height),AreaStyle);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(220));
GUILayout.BeginVertical();
GUILayout.EndVertical();
//Scrollview is populated with buttons here
GUILayout.EndScrollView();
GUILayout.EndArea();
}
The class that contains this function uses both a GUIStyle and GUISkin. Any help would be greatly appreciated.
Answer by devprincess · Sep 17, 2012 at 08:50 AM
Hi Josh, as far as I know, when you declare the scrollview height and width at the same value, the horizontal scrollbar goes away... here I let you some code for that... In case of showing the values, I will recommend to initialize any thing you want to be done before in the Awake function.
scrollPosition = GUILayout.BeginScrollView (
scrollPosition, GUILayout.Width (200), GUILayout.Height (200));