Hello,
I am trying to put a SelectionGrid into a ScrollView. I want the scroll view to have a fixed height, but adapt to the width of my editor window. Basically, I want the window to look like this (on the bottom right).
However, I don’t know where to specify the dynamic width and fixed height of the scroll view. The scroll view just stays small as in the screenshot.
Below is my code, I thought GUILayout.ExpandWidth(true) would at least expand the scroll view to fill the width of the editor window, but… nope. Any suggestions?
private void OnGUI()
{
// Create a list of previews from the prefabs list
List<GUIContent> paletteIcons = new List<GUIContent>();
foreach (GameObject prefab in prefabs)
{
Texture2D texture = AssetPreview.GetAssetPreview(prefab);
paletteIcons.Add(new GUIContent(texture, prefab.name));
}
paletteScrollPos = EditorGUILayout.BeginScrollView(paletteScrollPos, GUILayout.ExpandWidth(true));
paletteIndex = GUILayout.SelectionGrid(paletteIndex, paletteIcons.ToArray(), 6, GUILayout.Width(100), GUILayout.Height(100));
GUI.EndScrollView();
}