Skip to content

Commit 5e46982

Browse files
committed
add: hide
1 parent 1dc5737 commit 5e46982

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Assets/Code/Editor/SaveWindowEditor.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public class SaveWindowEditor : OdinEditorWindow
3333
private string JsonMessage = "❌ No JSON file found.";
3434
private string XmlMessage = "❌ No XML file found.";
3535

36+
// Foldout toggles
37+
private bool showPlayerPrefs = true;
38+
private bool showJson = true;
39+
private bool showXml = true;
40+
3641
[MenuItem("Tools/Save Window Editor")]
3742
private static void OpenWindow()
3843
{
@@ -46,18 +51,18 @@ private static void OpenWindow()
4651

4752
protected override void DrawEditor(int index)
4853
{
49-
DrawSection("🧠 PlayerPrefs Preview", GetPlayerPrefsPath(), PrefsMessage, DecodedPrefsData, ref scrollPrefs, Refresh, DeletePlayerPrefs);
54+
DrawFoldoutSection(ref showPlayerPrefs, "🧠 PlayerPrefs Preview", GetPlayerPrefsPath(), PrefsMessage, DecodedPrefsData, ref scrollPrefs, Refresh, DeletePlayerPrefs);
5055
GUILayout.Space(20);
51-
52-
DrawSection("📄 JSON File Preview", JsonFilePath, JsonMessage, DecodedJsonData, ref scrollJson, Refresh, DeleteJson);
56+
DrawFoldoutSection(ref showJson, "📄 JSON File Preview", JsonFilePath, JsonMessage, DecodedJsonData, ref scrollJson, Refresh, DeleteJson);
5357
GUILayout.Space(20);
54-
55-
DrawSection("📘 XML File Preview", XmlFilePath, XmlMessage, DecodedXmlData, ref scrollXml, Refresh, DeleteXml);
58+
DrawFoldoutSection(ref showXml, "📘 XML File Preview", XmlFilePath, XmlMessage, DecodedXmlData, ref scrollXml, Refresh, DeleteXml);
5659
}
5760

58-
private void DrawSection(string title, string path, string message, string data, ref Vector2 scrollPos, Action refreshAction, Action deleteAction)
61+
private void DrawFoldoutSection(ref bool foldout, string title, string path, string message, string data, ref Vector2 scroll, Action refresh, Action delete)
5962
{
60-
SirenixEditorGUI.Title(title, null, TextAlignment.Left, true);
63+
foldout = SirenixEditorGUI.Foldout(foldout, title);
64+
if (!foldout) return;
65+
6166
SirenixEditorGUI.BeginBox();
6267

6368
EditorGUILayout.LabelField("📁 Save Location", EditorStyles.boldLabel);
@@ -67,7 +72,7 @@ private void DrawSection(string title, string path, string message, string data,
6772

6873
if (!string.IsNullOrEmpty(data))
6974
{
70-
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(300));
75+
scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(300));
7176
EditorGUILayout.TextArea(data, GUILayout.ExpandHeight(true));
7277
EditorGUILayout.EndScrollView();
7378
}
@@ -79,12 +84,12 @@ private void DrawSection(string title, string path, string message, string data,
7984
GUILayout.Space(10);
8085
GUI.backgroundColor = new Color(0.6f, 0.9f, 1f);
8186
if (GUILayout.Button("🔄 Refresh", GUILayout.Height(35)))
82-
refreshAction.Invoke();
87+
refresh.Invoke();
8388

8489
GUILayout.Space(5);
8590
GUI.backgroundColor = new Color(1f, 0.4f, 0.4f);
8691
if (GUILayout.Button("🗑 Delete", GUILayout.Height(35)))
87-
deleteAction.Invoke();
92+
delete.Invoke();
8893

8994
GUI.backgroundColor = Color.white;
9095
SirenixEditorGUI.EndBox();

0 commit comments

Comments
 (0)