- Home /
Selectiongrid formatting with guistyle.wordwrap
Im using a selection grid for a simple table that i need to display. the window theyre in is fixed size with a fixed horizontal internal window and a scrollable vertical one. When an entry is too long i need it to use a new line like, say, excel would. by default the end gets chopped off
The only option in guistyle that seemed to make sense was guistyle.wordwrap. however when i set this to true it has the desired effect by going to the next line when neccessary but it also creates a huge gap between each one
i cant even see another entry in the window to show how big the gap is! Any ideas how i can fix this? or is there something else that provides a grid like selectiongrid?
void OnGUI () {
windowRect = GUI.Window(0, windowRect, GuiFunc, "Record");
}
Rect insideWindow;
void GuiFunc(int id)
{
GUI.BeginGroup(insideWindow);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, new GUIStyle());
GUILayout.SelectionGrid(0, gui, 2, listStyle);
GUILayout.EndScrollView();
if (GUILayout.Button("Close"))
{
mouse = false;
guiOn = false;
}
GUI.EndGroup();
GUI.DragWindow();
}
void Start () {
windowRect = new Rect(Screen.width/2 - 170, Screen.height/2 - 150, 340, 300);
insideWindow = new Rect(0, 0, 340, 1000);
listStyle.normal.textColor = Color.white;
listStyle.padding.left =
listStyle.padding.right =
listStyle.padding.top =
listStyle.padding.bottom = 4;
listStyle.fixedWidth = 150;
//listStyle.fixedHeight = 30;
//listStyle.stretchHeight = true;
listStyle.wordWrap = true;
listStyle.clipping = TextClipping.Overflow;
}
that was another line i was testing. Its the same regardless of whether its not set, set to .overflow or .clip thanks for the suggestions
It's strange, looks like your string is filled with white space... Are you getting text from somewhere, or just putting strings directly?
Answer by CaJerry87 · Dec 20, 2016 at 07:46 AM
This should answer what you're looking for. "How to Adjust the width and Height of your BeginHorizontal or BeginVertical" which helps with Custom Inspector Layout... http://answers.unity3d.com/answers/1288008/view.html
Your answer
Follow this Question
Related Questions
Styling an individual button in SelectionGrid 0 Answers
SelectionGrid layout and style issues 1 Answer
GUI style causing problem 0 Answers
Is it possible to detect which GUIStyleState is used? 2 Answers