EditorGUILayout.Foldout(), bug or doing it wrong?

I have this script:

bool showingEquipment = false;
showingEquipment = EditorGUILayout.Foldout(showingEquipment, "Equipment");
if (showingEquipment)
{
	EditorGUILayout.LabelField("Test");
}

It is showing the foldout in the editor, however it seems like I cannot change it from false to true and vice versa.

Any suggestions?

the problem is your showingEquipment variable is in the wrong place. It needs to persist thus you need to put it outside of the method.

Thanks alot.