GUI.BeginScrollView ignoring each GUI.Label element?

Hi Everyone!

I’m having some slight difficulty with a script of mine. I’m writing a coloured chat box which works very well, the issue is, when a new chat message is added, the scroll view seems to ignore it, making the text clip.

Please see the code below;

Code Removed

I originally achieved this using the GUILayout method, however, this method proved to be very limited so I am converting it to use the GUI system.

1 Answer

1

Ok, so. The interesting thing is this.

I have been able to compensate the height by creating a new private variable called scrollViewHeight, and changing the code appropriately.

The reason this did not work is because I set a static height of the view area. By using the scrollViewHeight variable, I have been able to modify the view area sufficiently.

Before;
GUI.BeginScrollView(new Rect(2,Screen.height-Screen.height/4-18,Screen.width/4,Screen.height/4),scrollPos,new Rect(0,0,Screen.width/4-18, Screen.height/4),false,true);

After;
GUI.BeginScrollView(new Rect(2,Screen.height-Screen.height/4-18,Screen.width/4,Screen.height/4),scrollPos,new Rect(0,0,Screen.width/4-18, scrollViewHeight),false,true);