Skip to content

Commit 97ca7ad

Browse files
authored
Merge pull request #40 from notargs/mv_prefs_to_settings
Rename MCPPreferences to MCPSetting and change it to be placed in PlayerSettings
2 parents cfc42bd + 4c41422 commit 97ca7ad

10 files changed

Lines changed: 50 additions & 50 deletions

File tree

README.ja.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ UPM(Unity Package Manager)を介してインストールできます。
7676
```
7777

7878
### Initial Setup
79-
1. Unity Editorで`Edit > Preferences > Unity Natural MCP`を開く
79+
1. Unity Editorで`Edit > Project Settings > Unity Natural MCP`を開く
8080
2. MCPサーバーのポート番号を設定(デフォルト: 8090)
8181
3. `Refresh` ボタンをクリックして設定を反映
8282

83-
![Preference](docs/images/preferences.png)
83+
![Settings](docs/images/settings.png)
8484

8585
### Claude Code
8686
RepositoryをCloneし、次のコマンドを利用して、ClaudeCodeにMCPサーバーを登録します。
@@ -117,7 +117,7 @@ networkingMode=mirrored
117117

118118
しかしながら、C#サーバー側でlocalhostにバインドした場合、期待通りに動作せず、接続が失敗する場合があります。
119119

120-
これを回避するためには、Unityの`Edit > Preferences > Unity Natural MCP`より、IPAddressを`*`に設定し、`Refresh`を実行します。
120+
これを回避するためには、Unityの`Edit > Project Settings > Unity Natural MCP`より、IPAddressを`*`に設定し、`Refresh`を実行します。
121121

122122
> [!CAUTION]
123123
> セキュリティ上の観点から、IP Addressに`*`を指定することは本来推奨されません。
@@ -183,7 +183,7 @@ public class MyCustomMCPToolBuilder : McpBuilderScriptableObject
183183
### 3. Create ScriptableObject
184184
1. Unity Editorでプロジェクトウィンドウを右クリック
185185
2. `Create > UnityNaturalMCP > My Custom Tool Builder` を選択してScriptableObjectを作成
186-
3. `Edit > Preferences > Unity Natural MCP > Refresh` から、MCPサーバーを再起動すると、作成したツールが読み込まれます。
186+
3. `Edit > Project Settings > Unity Natural MCP > Refresh` から、MCPサーバーを再起動すると、作成したツールが読み込まれます。
187187

188188
### Best practices for Custom MCP Tools
189189

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ You can install via UPM (Unity Package Manager):
7676
```
7777

7878
#### Initial Setup
79-
1. Open `Edit > Preferences > Unity Natural MCP` in Unity Editor
79+
1. Open `Edit > Project Settings > Unity Natural MCP` in Unity Editor
8080
2. Set the MCP server port number (default: 8090)
8181
3. Click the `Refresh` button to apply the settings
8282

83-
![Preference](docs/images/preferences.png)
83+
![Setting](docs/images/settings.png)
8484

8585
### Claude Code
8686
Clone the repository and use the following command to register an MCP server with ClaudeCode.
@@ -118,7 +118,7 @@ In mirror mode, you can communicate between WSL2 and the host OS via localhost.
118118

119119
However, when the C# server binds to localhost, it may not work as expected and connections may fail.
120120

121-
To work around this, set the IP Address to `*` in Unity's `Edit Preferences > Unity Natural MCP` and execute `Refresh`.
121+
To work around this, set the IP Address to `*` in Unity's `Edit > Project Settings > Unity Natural MCP` and execute `Refresh`.
122122

123123
> [!CAUTION]
124124
> From a security perspective, specifying `*` for the IP Address is not normally recommended.
@@ -184,7 +184,7 @@ public class MyCustomMCPToolBuilder : McpBuilderScriptableObject
184184
### 3. Create ScriptableObject
185185
1. Right-click in the project window in Unity Editor
186186
2. Create ScriptableObject by Select `Create > UnityNaturalMCP > My Custom Tool Builder`
187-
3. From `Edit > Preferences > Unity Natural MCP > Refresh`, restart the MCP server to load the created tools.
187+
3. From `Edit > Project Settings > Unity Natural MCP > Refresh`, restart the MCP server to load the created tools.
188188

189189
### Best practices for Custom MCP Tools
190190

UnityNaturalMCPServer/Editor/McpPreference.cs renamed to UnityNaturalMCPServer/Editor/MCPSetting.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace UnityNaturalMCP.Editor
44
{
5-
[FilePath("UnityNaturalMCPPreferences.asset", FilePathAttribute.Location.PreferencesFolder)]
6-
public class McpPreference : ScriptableSingleton<McpPreference>
5+
[FilePath("UnityNaturalMCPSetting.asset", FilePathAttribute.Location.ProjectFolder)]
6+
public sealed class MCPSetting : ScriptableSingleton<MCPSetting>
77
{
88
public string ipAddress = "localhost";
99
public int port = 8090;
File renamed without changes.

UnityNaturalMCPServer/Editor/McpPreferenceProvider.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

UnityNaturalMCPServer/Editor/McpServerApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Dispose()
2626

2727
public async UniTask Run(CancellationToken token)
2828
{
29-
var preference = McpPreference.instance;
29+
var preference = MCPSetting.instance;
3030
var mcpEntPoint = $"http://{preference.ipAddress}:{preference.port}/mcp/";
3131
_httpListener.Prefixes.Add(mcpEntPoint);
3232
_httpListener.Start();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Collections.Generic;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
namespace UnityNaturalMCP.Editor
6+
{
7+
internal sealed class McpSettingProvider : SettingsProvider
8+
{
9+
private const string SettingPath = "Project/Unity Natural MCP";
10+
private readonly UnityEditor.Editor _settingsEditor;
11+
12+
[SettingsProvider]
13+
public static SettingsProvider CreateSettingProvider()
14+
{
15+
return new McpSettingProvider(SettingPath, SettingsScope.Project, null);
16+
}
17+
18+
public McpSettingProvider(string path, SettingsScope scopes, IEnumerable<string> keywords) : base(path, scopes, keywords)
19+
{
20+
var settings = MCPSetting.instance;
21+
settings.hideFlags = HideFlags.HideAndDontSave & ~HideFlags.NotEditable;
22+
UnityEditor.Editor.CreateCachedEditor(settings, null, ref _settingsEditor);
23+
}
24+
25+
public override void OnGUI(string searchContext)
26+
{
27+
EditorGUI.BeginChangeCheck();
28+
_settingsEditor.OnInspectorGUI();
29+
if (GUILayout.Button("Refresh"))
30+
{
31+
McpServerRunner.RefreshMcpServer();
32+
}
33+
if (EditorGUI.EndChangeCheck())
34+
{
35+
MCPSetting.instance.Save();
36+
}
37+
}
38+
}
39+
}

UnityNaturalMCPServer/Editor/McpPreferenceProvider.cs.meta renamed to UnityNaturalMCPServer/Editor/McpSettingProvider.cs.meta

File renamed without changes.

docs/images/preferences.png

-38.6 KB
Binary file not shown.

docs/images/settings.png

72.4 KB
Loading

0 commit comments

Comments
 (0)