List<int> num = new List<int>();
void OnGUI()
{
GUI.color = Color.white;
scrollPos =
EditorGUILayout.BeginScrollView(scrollPos, true,true,
GUILayout.ExpandWidth(true), GUILayout.Height(position.height));
foreach (KeyValuePair<GameObject, string> pair in dictio)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.ObjectField(pair.Key, typeof(GameObject), true);
num.Add(EditorGUILayout.TextField(pair.Value).Length);
EditorGUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
window.maxSize = new Vector2(num[], position.height);
}
after the loop I want to find the highest value from the List num and set it as the window width size.
Max?var maxWidth = 0;and then for each iteration domaxWidth = Mathf.Max(maxWidth, EditorGUILayout.TextField(pair.Value).Length);without the need for iterating yet another list ...