- Home /
Question by
MaceB · Dec 02, 2018 at 05:06 AM ·
inspectorcustom editorcustom inspectorobjectfieldfoldout
Custom Inspector: How to Align EditorGUILayout.Objectfield in a Horizontal Group with other EditorGUILayout.Objectfield that aren't in Horizontal Groups?
I've made a Foldout and a Objectfield in a horizontal group but the Objectfield isn't aligning with the other Objectfields in my inspector that aren't in horizontal groups.
I would like for the 2 Objectfields which are inside their horizontal groups to align with the other Objectfields and also adjust their width with them when the inspector width is changed.
EditorGUILayout.BeginHorizontal();
showCurrentLevelFoldout = EditorGUILayout.Foldout(showCurrentLevelFoldout, "Current Level");
progressScript.currentLevelBackgroundImage = (Image)EditorGUILayout.ObjectField(progressScript.currentLevelBackgroundImage, typeof(Image), true);
EditorGUILayout.EndHorizontal();
if (showCurrentLevelFoldout) {
EditorGUI.indentLevel++;
progressScript.currentLevelFill = (Image)EditorGUILayout.ObjectField("Current Level Fill", progressScript.currentLevelFill, typeof(Image), true);
progressScript.currentLevelText = (Text)EditorGUILayout.ObjectField("Current Level Text", progressScript.currentLevelText, typeof(Text), true);
EditorGUI.indentLevel--;
}
EditorGUILayout.BeginHorizontal();
showNextLevelFoldout = EditorGUILayout.Foldout(showNextLevelFoldout, "Next Level");
progressScript.nextLevelBackgroundImage = (Image)EditorGUILayout.ObjectField(progressScript.nextLevelBackgroundImage, typeof(Image), true);
EditorGUILayout.EndHorizontal();
if (showNextLevelFoldout)
{
EditorGUI.indentLevel++;
progressScript.nextLevelFill = (Image)EditorGUILayout.ObjectField("Next Level Fill", progressScript.nextLevelFill, typeof(Image), true);
progressScript.nextLevelText = (Text)EditorGUILayout.ObjectField("Next Level Text", progressScript.nextLevelText, typeof(Text), true);
EditorGUI.indentLevel--;
}
Here's what's happening:
Here's what I want to be happening:
screen-shot-2018-12-01-at-114046-pm.jpg
(99.6 kB)
screen-shot-2018-12-01-at-115311-pm.png
(44.1 kB)
Comment
If someone could $$anonymous$$ch me how to do a line break in these questions, that'd be cool too. I did the double space + enter but as you can see, it didn't work out