- Home /
Vertical Scrollbar GUI.Label
I've a highscore system in my game which is showing top 100 scores, I make scrolling label for this section.
The following code showing me both vertical and horizental scrollbar, But I only need vertical scrollbar, Any ideas?
//Fetch the right size
nameDimensions = GUI.skin.label.CalcSize(new GUIContent(infoValueName));
scoreDimensions = GUI.skin.label.CalcSize(new GUIContent(infoValueScore));
//Make the dynamic scrollbar system
scrollViewVector = GUI.BeginScrollView (Rect(Screen.width / 3, Screen.height / 4
, scoreDimensions.x + nameDimensions.x, nameDimensions.y)
, scrollViewVector, repValueName, false, true);
GUI.Label(repValueName, infoValueName);
GUI.Label(repValueScore, infoValueScore);
GUI.EndScrollView();
Comment
Answer by Berenger · Jun 03, 2012 at 04:37 PM
CalcSize : This function does not take wordwrapping into account.
This means that if your string is to long, it won't be contained in Screen.width / 3, hence the horizontal sb. I suggest you use GUILayout and GUILayout.MaxWidth to make sure your labels are not as wide as the scroll view.