I’m having trouble getting a scrollview working properly in a GUI.Window.
Basically I want to create something sort of like a journal, that will have a log of information that you can scroll thru. I’m choosing a window over a textbox as it may not just contain text but may include buttons as well. I dont know how to get a scrollview working in a window though, it doesnt seem to be working in the window function.
Oh, and I’m using C# as well.
Any advice would be appreciated! Thanks.
Without seeing code it’s hard to understand exaclty what’s going wrong, but here’s a simple java example that shows it working.
var scrollPosition : Vector2 = Vector2.zero;
function OnGUI ()
{
windowRect = GUI.Window (0, Rect(Screen.width/2 - 200, Screen.height/2 - 50, 400, 100), DoMyWindow, "My Window");
//Parameters
//Id - Id of window
//clientRect - Location to draw it (this is center screen)
//func - Function that draws the window contents
//text - Text to display in the top bar
}
function DoMyWindow (windowID : int)
{
//Start Scrollview
scrollPosition = GUI.BeginScrollView (Rect(0,0,400,100), scrollPosition, Rect(0,0,400,400));
//Parameters
//Position - Position and size to draw the scroll view
//scrollPosition - Variable that will hold the current scroll location (X.Y)
//viewRect - Area Inside the scroll view - should always be bigger than the size in Position
//Draw stuff in the scroll area
if (GUI.Button (Rect (10,20,100,20), "Hello World"))
print ("Got a click");
//End Scrollview
GUI.EndScrollView();
}
Maybe that can help you spot what’s going on in your code
EDIT: Fixed readablity of comments
1 Like