Hi All,
I am adding a control to the inspector window and want to have a row of toggle controls, well a grid actually, exactly like the one you see when you go to Project->Physics to enable and disable the collision stuff.
I can get sort of horizontal layout but there is a huge gap inbetween controlls. How do I bunch them up nice and tight as in the Project->Physics control? Here is my code that does it badly.
public override void OnInspectorGUI()
{
int x, y;
bool state;
if(_target.MapEditorToolName == "")
{
_target.MapEditorToolName = _target.initialName;
}
EditorGUILayout.BeginVertical();
EditorGUILayout.PrefixLabel("Name");
_target.MapEditorToolName = EditorGUILayout.TextField(_target.MapEditorToolName, GUILayout.ExpandWidth(false));
EditorGUILayout.Separator();
EditorGUILayout.Separator();
for(y = 0; y < gridys; y++) /* fetch grid */
{
EditorGUILayout.BeginHorizontal();
for(x = 0; x < gridxs; x++)
{
if(grid[y, x] == 0)
state = false;
else
state = true;
EditorGUILayout.Toggle("", state, GUILayout.ExpandWidth(false));
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
//update and redraw:
if(GUI.changed)
{
EditorUtility.SetDirty(_target);
}
}