- Home /
Chat Scrollbar not working correctly
Hi!
I've got my chat and I need my scrollbar to allow you to scroll the bar. But my problem is. It doesn't show my scrollbar when I start (which is good) but when the messages starts overflowing, it doesn't appear and I can't scroll. What should I do?
Here is my code:
scrollPosition = GUI.BeginScrollView(new Rect(0, Screen.height - 150, 400, 130), scrollPosition, new Rect(0, 0, 0, 130));
GUI.Label(new Rect(5, 0, 390, 5), communication, myStyle);
GUI.EndScrollView();
Thanks
Answer by thornekey · Jun 01, 2014 at 03:23 PM
this is because there is nothing to scroll.. to make it always there you must tell it to never be hidden:
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(400), GUILayout.Height(130));
if u use a GUILayout you get options.
I don't know how to work with GUILayout and I am not planning to learn it either.
why arent you willing to learn it? it is much cleaner in your scripts... you should always be willing to learn new things.. especially when it comes to program$$anonymous$$g or youll always be slandered as a noob.
It is just that I want to be very specific on where I have my GUIs. What I have understood, that's a bit hard to do in GUILayout.
Answer by zharik86 · Jun 01, 2014 at 07:22 PM
Your error in initialization of the second rectangle in BeginScroll (). You write that its width is equal 0. Therefore you see nothing. Set value more than 0. For example:
scrollPosition = GUI.BeginScrollView(new Rect(0, Screen.height - 150, 400, 130), scrollPosition, new Rect(0, 0, 400, 130));
If you need "scrollbar" view texture, that change to:
scrollPosition = GUI.BeginScrollView(new Rect(0, Screen.height - 150, 400, 130), scrollPosition, new Rect(0, 0, 400, 260));
GUI.Label(new Rect(5, 5, 390, 20), communication, myStyle);
GUI.EndScrollView();
How work with GUI.BeginScroll(), see my pregoing response
Your answer
