- Home /
Adding line breaks when the text is bigger?
In my game i have a text files that contains Question and Answers of different categories. I have stored it in an XML file and displayed the questions and options based on current string length. Below is the code i used:
GUILayout.Label(m_ReadTextXML.m_question,new GUILayoutOption[{GUILayout.ExpandHeight(true),GUILayout.ExpandWidth(true)});
GUI.contentColor = Color.black;
m_optLen = GUI.skin.label.CalcSize(new GUIContent(m_ReadTextXML.m_option1));
GUILayout.Button(m_ReadTextXML.m_option1,m_guiTxtFnt.button, GUILayout.Width(m_optLen.x*1.15f),GUILayout.Height(m_optLen.y*1.5f));
I have both normal and match the following type. In match type questions have text that should me matched with images.Have displayed it in row wise. In some questions text length is too bigger that overlaps with the images. Help me to add line breaks for such texts. Thanks in advance.
Answer by Unity_gamer · Mar 23, 2014 at 12:52 PM
Use word wrap in GUI Skin .
Check this post http://answers.unity3d.com/questions/543927/guilayoutlabel-not-full-width-ie-words-break.html
Thanks
Or You can use custom function to do word wrapping This link will help you for that
Your answer
Follow this Question
Related Questions
GUI Label Text Sizing problem 1 Answer
OnGui doesn't work 2 Answers
GUI Text to GUI Label Script? 1 Answer
How to clear textures on screen? 1 Answer
GUILabel to GUIText or Textmesh 0 Answers