- Home /
Question by
Hathi28 · Jul 03, 2013 at 05:57 PM ·
iostouch screenscroll-wheel
How do I add a scroll bar to this code or make the current one on here work; this is for iOS. So when thee player clicks the screen, he or she, can scroll down with their finger.
var vSbarValue : float;
function OnGUI (){
vSbarValue = GUI.VerticalScrollbar(Rect (887.5, 150, 100, 300), vSbarValue, 1.0, 10.0, 0.0);
//Font Size and Color Change
var statsStyle = new GUIStyle("label");
statsStyle.fontSize = 30;
var buttonStyle = new GUIStyle("Button");
buttonStyle.fontSize = 17.5;
var statStyle = new GUIStyle("Label");
statStyle.fontSize = 17.5;
var twoStyle = new GUIStyle("Label");
twoStyle.fontSize = 25;
var fourStyle = new GUIStyle("Label");
fourStyle.fontSize = 25;
var pictureStyle = new GUIStyle("Label");
pictureStyle.fontSize = 20;
//Statistics Title GUI Design
GUI.contentColor = Color.black;
GUI.backgroundColor = Color.white;
GUI.Label(Rect(450,100,250,100), "Statistics",statsStyle);
GUI.Label(Rect(470,135,250,100), "Pictures",pictureStyle);
//Statistics Sub-Title GUI Design
GUI.Label(Rect(200,175,250,100), "High Scores for Two Choices:",statStyle);
GUI.Label(Rect(600,175,250,100), "High Scores for Four Choices:",statStyle);
//Two Choices GUI Design
GUI.Label(Rect(175,200,250,100), "A - Z = ",twoStyle);
GUI.Label(Rect(175,275,250,100), "Z -A = ",twoStyle);
GUI.Label(Rect(175,350,250,100), "Random = ",twoStyle);
//Four Choices GUI Design
GUI.Label(Rect(575,200,250,100), "A -Z = ",fourStyle);
GUI.Label(Rect(575,275,250,100), "Z -A = ",fourStyle);
GUI.Label(Rect(575,350,250,100), "Random = ",fourStyle);
if(GUI.Button(Rect(150,100,150,30), "Back to Menu",buttonStyle)){
Application.LoadLevel("Menu");
}
if(GUI.Button(Rect(750,100,150,30), "Next Page",buttonStyle)) {
Application.LoadLevel("Statistics2");
}
}
Comment
I've fixed your formatting; use the '101010' button to paste code.
Answer by iwaldrop · Jul 03, 2013 at 07:27 PM
You need to use a ScrollView.
Vector2 mPos;
void OnGUI()
{
mPos = GUILayout.BeginScrollView(mPos);
{
for (int i = 0; i < 100; i++)
GUILayout.Label(string.Format("Label {0}", i));
}
GUILayout.EndScrollView();
}
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to tilt the gameobject based of Input.Acceleration? 0 Answers
Facebook unity sdk: is it possible to send friend invites/app requests to non app users ? 1 Answer
Audio: how do I immediately play a new audioclip without delay(code included)? 2 Answers
Unity + XCode Problem (really wierd) 0 Answers