Question by
tintinkungz · Aug 17, 2021 at 07:17 AM ·
editor-scriptingboolguilayoutfoldout
Have Problem Storing GUILayout Foldout Bool
So im trying to save bool foldout in some file system so that the foldout gui wont reset to false again is the editor is reload
rn im just declare the bool like this
private bool _showTransforms;
private bool _showTargets;
private bool _showConstraints;
And i make foldout out of it like this
private void DrawFoldOut(string folderName, GUIStyle style, string styleType,
List variableField, ref bool folderBool)
{
EditorGUILayout.BeginVertical((GUIStyle) styleType);
// folderBool is the bool i decare above
folderBool = GUILayout.Toggle(folderBool, folderName, style);
if(folderBool)
{
//ignore this (this is how i display the variable)
foreach (Field field in variableField)
{
EditorGUI.indentLevel += 2;
EditorGUILayout.PropertyField(field.ID, new GUIContent(field.Name, field.ToolTip));
EditorGUI.indentLevel -= 2;
}
}
EditorGUILayout.EndVertical();
};
Problem is this code does not work because the folded bool will turn false again if theres some editor reload and its rlly annoy me when i fold all of my variable out and it goes unfold again if i enter play mode. So pls give me some example of how to fix it
Comment