var wasScrolling : boolean = false;
var scrollPosition : Vector2;
var longString = "This is a long-ish string This is an sized label. This is an sized label. This is an sized label. This is an sized label. This is an sized label. ";
function OnGUI () {
var rectForDescription : Rect = Rect(100,100,100,100);
GUILayout.BeginArea(rectForDescription);
scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (100), GUILayout.Height (100));
GUILayout.Label (longString);
GUILayout.EndScrollView ();
GUILayout.EndArea();
if( Event.current.type==EventType.MouseDown && rectForDescription.Contains(Event.current.mousePosition) ) {
wasScrolling = true;
print("down");
}
if( Event.current.type==EventType.MouseDrag && wasScrolling==true ) {
print(Event.current.delta.y);
scrollPosition.y+=Event.current.delta.y;
}
if( Event.current.type==EventType.MouseUp && wasScrolling == true) {
print("end scrolling");
wasScrolling = false;
}
}
iOS Developer
Tuesday, May 3, 2011
Unity3d code clip : auto height lable and mouse touchable scrolling
Subscribe to:
Posts (Atom)