I’m trying to build a GUI scrolling textbox where the content will be of unknown length and will change (but not user editable).
While BeginScrollView is nice, I am forced to determine the scroll height before I build any content, not that there’s any way to poll the height of content or to get a TextArea to auto-adjust its height depending on its content.
Don’t post the same thing in 2 different forums. Also - try and be a bit more polite when you ask for help (referring to your response in the other forum). You’re not effectively describing what the issue you’re trying to solve is. Why can’t you use a ScrollView? Why can’t you use a GUILayout.Label to print the text to the screen since it will resize for you?
I posted it in the GUI forum first, but there seems to be low-traffic over there so I also posted it here, because it is also a scripting issue.
Why can’t you use a ScrollView?
Because I don’t know how tall the text needs to be. To quote myself, “I am forced to determine the scroll height before I build any content.”
Why can’t you use a GUILayout.Label
Because I can’t position it where I want to? GUILayout decides the positioning for me, and sorry, but I’m working to another designer’s design. I can’t just go all willy nilly and let Unity decide where things go.
Also, the text still doesn’t scroll.
You’re not effectively describing what the issue you’re trying to solve is
Does this help?
I suppose I should note, that scrolling area is positioned at 15,427 relative to the upper left corner of the GUI.Window
Simply put:
I need a scrolling text box for text of indeterminate (at compile-time) length.
Ok - now I see. The only way I know of to do what you’re talking about is to use GUILayout.BeginScrollView(). If you need absolute positioning then I would wrap the ScrollView in a GUI.BeginGroup()/EndGroup() which is positioned where you need it to be.
Took some finagling (the Group had to be positioned about 15 pixels left and 40 pixels up and needed to be 10 pixels wider and 40 pixels taller) but it worked.
Hello all i am working on a unity project and trying to add a scrollbar within a C# Script
The code currently generates a popup window that the user can close once done reading the text that is added in the unity editor. I am trying to get a solution to this issue soon any help with this is greatly appreciated thanks.
Try the post directly above your own. That goes inside the OnGui() method of a MonoBehaviour script, attached to any game object.
I’ve only barely touched the surface of Unity 5’s new gui stuff, amounting to the placement of small text labels. So I can’t offer any help on that front.