Hello everyone. I am making chat for my game and wanted to know how could I implement a scrollbar for my chat window. Basically there’s max messages and at start there will be 0 messages. So the scrollbar would be full height, but as more messages are being typed it should decrease in size. Also how do I make the text area scrollable?
I found out all of that myself. My tip: use Scrollview with some very smart Scrollview’s height changing using functions like CalcHeight and CalcSize
Tell me that you googled “Unity Scrollbar”, and looked at GUI.VerticalScrollbar?
1 Like
I did. But I am asking how to program the logic of it, like make it scroll the textarea for example.
if you don’t want to use Unitys built in VerticalScrollbar or any other GUI solutions like NGUI etc then it won’t be to hard to make a crappy version yourself. But I must ask; why don’t you want to use Unitys GUI? or another package?
But anyways…
you’ll want to do is test to see if the mouse is over / clicked on your ‘slider’, if it is set it to the position of the mouse to make the actual slider scroll part. And obviously clamp it’s y position to whatever you wish…
Then for your object to scroll you’d want to set its position to the y value of the slider or something similar, that won’t do it completely, you’ll want to add some more logic to actual scroll properly, but that’s the base so you could play around with it