- Home /
Word Wrapping Gui.Box
Been trying for a while now. Thanks for all the help that I've been getting. I've learned a lot so far. So my question.. I have changed the width of my Gui.Box and need it get it to wrap the words.
public class About : MonoBehaviour {
public Vector2 scrollPosition = Vector2.zero; public TextAsset textAsset; public Texture texture; public GUIStyle style;
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () {
}
void OnGUI(){
GUI.Box(new Rect(Screen.width / 8 + 50, 0, 1024, 1024), texture);
GUI.BeginGroup(new Rect(Screen.width / 4 +50, Screen.height / 4 -50, 600, 600));
//Begin Scroll Slide
scrollPosition = GUI.BeginScrollView(new Rect(0, 0, 600, 500), scrollPosition, new Rect(0, 0, 600, 500), alwaysShowHorizontal: true, alwaysShowVertical: true);
if(GUI.skin.customStyles.Length > 0)
//Add content to the scroll area.
GUI.Box(new Rect(0, 0, 600, 500), textAsset.text, style.wordWrap = true);
//End Scroll Slide
GUI.EndScrollView();
GUI.EndGroup();
}
}
any clue how to get it to work correctly?
Answer by Eric5h5 · Mar 14, 2011 at 04:04 AM
Check "word wrap" in the GUIStyle in the inspector.
I should of said that the error was saying
" The best overloaded method match for UnityEngine.GUI.Box(UnityEngine.Rect, string, Unity,Engine.GUIStyle) has some invalid arguments"