Scroll Bar
Scrolls are very common in every language. Generally, the scroll is divided up into pages, which are infrequently distinct sheets of papyrus or parchment glued with each other at the edges, or may be marked divisions of a continuous roll of writing material.
The scroll usually allows you to expose the big text in a small area. You can add as much content in the scroll view that can be shown through scroll bar. It wraps the text from the bottom or right side according to requirement so that you can add more text in it.
We can also make scroll in unity.
void OnGUI ()
{
GUI.skin = optionsSkin;
windowRect = new Rect(windowMargin.x, windowMargin.y, 195,height-150);
GUI.Window(0, windowRect, (GUI.WindowFunction)DoWindow, "");
}
This will call another function:-
void DoWindow (int windowID)
{
Vector2 listSize = new Vector2(175,height-170);
Rect rScrollFrame = new Rect(listMargin.x, listMargin.y, listSize.x, listSize.y);
Rect rList = new Rect(0, 0, rowSize.x, numRows*rowSize.y);
scrollPosition = GUI.BeginScrollView (rScrollFrame, scrollPosition, rList, false, false);
Rect rBtn = new Rect(0, 0, rowSize.x, rowSize.y);
for (int iRow = 0; iRow < numRows; iRow++)
{
// draw call optimization: don't actually draw the row if it is not visible
if ( rBtn.yMax >= scrollPosition.y && rBtn.yMin <= (scrollPosition.y + rScrollFrame.height) )
{
bool fClicked = false;
Texture finalImage = camshaft;
if(iRow==0)
{
finalImage = camshaft;
}
else if(iRow==1)
{
finalImage = engine;
}
else if(iRow==2)
{
finalImage = exhaust;
}
else if(iRow==3)
{
finalImage = suspension;
}
else if(iRow==4)
{
finalImage = wheel;
}
if ( iRow == selected )
{
fClicked = GUI.Button(rBtn, finalImage, rowSelectedStyle);
}
else
{
fClicked = GUI.Button(rBtn, finalImage);
}
// Allow mouse selection, if not running on iPhone.
// Note: this code will be triggered
if ( fClicked && Application.platform != RuntimePlatform.IPhonePlayer )
{
ClickedOn(iRow);
}
}
rBtn.y += rowSize.y+1;
}
GUI.EndScrollView();
}
This will give you Scroll bar.... Be free to code...... :)
0 Comment(s)