- Home /
Scrollview not showing scroll bar and not scrolling
I am having a problem with the Scrollview. i am not getting the scroll bar to show up and it is not scroll.
public Vector2 scrollPostion = Vector2.zero;
...
void OnGUI()
{
if (listdownloaded)
{
StopCoroutine("getlevels");
GUI.Window(1, new Rect(Screen.width*0.1f,Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f), customlevelbuttonlist, "Custom Levels");
}
else if(...
}
void customlevelbuttonlist(int windowID)
{
float count=0;
scrollPostion=GUI.BeginScrollView(new Rect(Screen.width*0.05f, Screen.height*0.05f, Screen.width*0.75f, Screen.height*0.7f), scrollPostion, new Rect(0,0, Screen.width*0.7f, Screen.height*0.65f));
foreach(CustomLevel level in CustomLevels)
{
if(GUI.Button(new Rect(0, buttonheight*count, Screen.width*0.7f, 45), level.Name))
{
Commons.levelLocation=CustomLevels[(int)count].location;
updatepercent();
UpDateAchievements();
Application.LoadLevel(gotoSceneIndex);
Debug.Log(CustomLevels[(int)count].location.ToString());
Debug.Log(SceneIndex);
}
count++;
}
GUI.EndScrollView();
}
I am not sure if i am doing something small wrong or what. this is the first time i have tried to work with scrollviews, so any help i can get would be great.
Answer by zharik86 · May 20, 2014 at 07:05 PM
About GUI Scroll see my pregoing response. In your case in line 18
scrollPostion=GUI.BeginScrollView(new Rect(Screen.width*0.05f, Screen.height*0.05f, Screen.width*0.75f, Screen.height*0.7f), scrollPostion, new Rect(0,0, Screen.width*0.7f, Screen.height*0.65f));
you set dimension on screen your scroll, how Screen.width*0.75f, Screen.height*0.7f. But dimension self scroll is Screen.width*0.7f, Screen.height*0.65f. Of couse, you don't see your scroll. Simple change your dimension scroll, for example, little more your screen dimension of scroll:
scrollPostion=GUI.BeginScrollView(new Rect(Screen.width*0.05f, Screen.height*0.05f, Screen.width*0.75f, Screen.height*0.7f), scrollPostion, new Rect(0,0, Screen.width*0.8f, Screen.height*0.75f));
To clarify the above comment:
When you declare a BeginScrollView() you give it two Rect(). The second Rect() needs to be slightly larger in order for the scroll bars to render properly.
Your answer
Follow this Question
Related Questions
Changing the scale of the scroll view 1 Answer
I am still able to scroll even though scroll type is clamped? 0 Answers
Smooth scrollbar movement on display release 0 Answers
How do i move the vertical scrollbar thumb using left-mouse click and dragging it ? 2 Answers
How can I create a Multi line Input Field with Scrollbar? 0 Answers