Skip to content

Commit c770a8c

Browse files
Add EditorPrefs management window for MCP configuration debugging (#491)
* Add EditorPrefs management window for MCP configuration debugging Meant to help with dev and testing, not so much the average user * Update MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Revert "Update MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs" This reverts commit 09bb4e1. * Reapply "Update MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs" This reverts commit 6ccbc5e. * Fix EditorPrefs type detection using sentinel values and null handling * Simplify EditorPrefs type detection using known type mapping and basic parsing Replace complex sentinel-based type detection with a dictionary of known pref types and simple TryParse fallback for unknown keys. Remove null handling and HasKey checks for known keys since they're defined in EditorPrefKeys. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent eea02d1 commit c770a8c

12 files changed

Lines changed: 755 additions & 7 deletions

MCPForUnity/Editor/MenuItems/MCPForUnityMenu.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ namespace MCPForUnity.Editor.MenuItems
77
{
88
public static class MCPForUnityMenu
99
{
10-
[MenuItem("Window/MCP For Unity/Setup Window", priority = 1)]
11-
public static void ShowSetupWindow()
12-
{
13-
SetupWindowService.ShowSetupWindow();
14-
}
15-
16-
[MenuItem("Window/MCP For Unity/Toggle MCP Window %#m", priority = 2)]
10+
[MenuItem("Window/MCP For Unity/Toggle MCP Window %#m", priority = 1)]
1711
public static void ToggleMCPWindow()
1812
{
1913
if (MCPForUnityEditorWindow.HasAnyOpenWindow())
@@ -25,5 +19,18 @@ public static void ToggleMCPWindow()
2519
MCPForUnityEditorWindow.ShowWindow();
2620
}
2721
}
22+
23+
[MenuItem("Window/MCP For Unity/Setup Window", priority = 2)]
24+
public static void ShowSetupWindow()
25+
{
26+
SetupWindowService.ShowSetupWindow();
27+
}
28+
29+
30+
[MenuItem("Window/MCP For Unity/EditorPrefs", priority = 3)]
31+
public static void ShowEditorPrefsWindow()
32+
{
33+
EditorPrefsWindow.ShowWindow();
34+
}
2835
}
2936
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using MCPForUnity.Editor.Windows;
3+
using UnityEditor;
4+
5+
namespace MCPForUnity.Editor.Services
6+
{
7+
/// <summary>
8+
/// Service for managing the EditorPrefs window
9+
/// Follows the Class-level Singleton pattern
10+
/// </summary>
11+
public class EditorPrefsWindowService
12+
{
13+
private static EditorPrefsWindowService _instance;
14+
15+
/// <summary>
16+
/// Get the singleton instance
17+
/// </summary>
18+
public static EditorPrefsWindowService Instance
19+
{
20+
get
21+
{
22+
if (_instance == null)
23+
{
24+
throw new Exception("EditorPrefsWindowService not initialized");
25+
}
26+
return _instance;
27+
}
28+
}
29+
30+
/// <summary>
31+
/// Initialize the service
32+
/// </summary>
33+
public static void Initialize()
34+
{
35+
if (_instance == null)
36+
{
37+
_instance = new EditorPrefsWindowService();
38+
}
39+
}
40+
41+
private EditorPrefsWindowService()
42+
{
43+
// Private constructor for singleton
44+
}
45+
46+
/// <summary>
47+
/// Show the EditorPrefs window
48+
/// </summary>
49+
public void ShowWindow()
50+
{
51+
EditorPrefsWindow.ShowWindow();
52+
}
53+
}
54+
}

MCPForUnity/Editor/Services/EditorPrefsWindowService.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MCPForUnity/Editor/Windows/EditorPrefs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
2+
<ui:VisualElement class="pref-item">
3+
<ui:VisualElement class="pref-row">
4+
<!-- Key and Known indicator -->
5+
<ui:VisualElement class="key-section">
6+
<ui:Label name="key-label" class="key-label" />
7+
</ui:VisualElement>
8+
9+
<!-- Value field -->
10+
<ui:TextField name="value-field" class="value-field" />
11+
12+
<!-- Type dropdown -->
13+
<ui:DropdownField name="type-dropdown" class="type-dropdown" choices="String,Int,Float,Bool" index="0" />
14+
15+
<!-- Action buttons -->
16+
<ui:VisualElement class="action-buttons">
17+
<ui:Button name="save-button" text="✓" class="save-button" tooltip="Save changes" />
18+
</ui:VisualElement>
19+
</ui:VisualElement>
20+
</ui:VisualElement>
21+
</ui:UXML>

MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefItem.uxml.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)