I made a text area, which is scrollable with scrollbars, and from scripts I can add new lines to it. I want to make the scrollbar to scroll down to the bottom when a new line is added. As I was searching for a solution on the internet I found this:
They wrote that the following code works (but no other explanation):
GameObject.Find (“Scroll Rect”).GetComponent().verticalNormalizedPosition = 0.5f;
It seems to me that they are in a more advanced level because this is all the help they needed, but I cannot figure out how to actually implement this solution. From other sources, and from looking in the documentation, it seems like that the verticalNormalizedPosition is what I need to use, but I don’t know how.
I tried using the following lines of codes, but It is still not working:
public ScrollRect scrollRect;
scrollRect = GetComponent();
Can somebody explain what is the problem? Or at least point me in the right direction. The Unity tutorials and other sources online unfortunately doesn’t cover this exact situation.