From 77fc0da11eee42162fcd34caafb7991fad5efd2f Mon Sep 17 00:00:00 2001 From: hatayama Date: Wed, 15 Apr 2026 17:08:40 +0900 Subject: [PATCH 1/4] Make Input System dependency optional --- .../PlayMode/uLoopMCP.Tests.PlayMode.asmdef | 2 +- Packages/packages-lock.json | 1 - .../Api/McpTools/RecordInput/InputRecorder.cs | 2 ++ .../RecordInput/InputRecordingFileHelper.cs | 2 ++ .../McpTools/RecordInput/RecordInputTool.cs | 20 ++++++++++++++++++- .../Api/McpTools/ReplayInput/InputReplayer.cs | 2 ++ .../McpTools/ReplayInput/ReplayInputTool.cs | 20 ++++++++++++++++++- .../SimulateKeyboard/SimulateKeyboardTool.cs | 1 - .../SimulateMouseInputTool.cs | 1 - .../UI/Recordings/RecordingsEditorWindow.cs | 2 ++ Packages/src/README.md | 11 ++++++---- Packages/src/TOOL_REFERENCE_ja.md | 4 ++-- Packages/src/package.json | 1 - README.md | 11 ++++++---- README_ja.md | 11 ++++++---- 15 files changed, 70 insertions(+), 21 deletions(-) diff --git a/Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef b/Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef index 3a5e95279..4a5045d85 100644 --- a/Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef +++ b/Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef @@ -31,4 +31,4 @@ } ], "noEngineReferences": false -} \ No newline at end of file +} diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index a67e70139..aaaf224ae 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -197,7 +197,6 @@ "depth": 0, "source": "embedded", "dependencies": { - "com.unity.inputsystem": "1.14.2", "com.unity.ugui": "1.0.0", "com.unity.nuget.newtonsoft-json": "3.2.1" } diff --git a/Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs b/Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs index 75114cb81..ba81c1f37 100644 --- a/Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs +++ b/Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs @@ -1,3 +1,4 @@ +#if ULOOPMCP_HAS_INPUT_SYSTEM #nullable enable using System; using System.Collections.Generic; @@ -476,3 +477,4 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state) } } } +#endif diff --git a/Packages/src/Editor/Api/McpTools/RecordInput/InputRecordingFileHelper.cs b/Packages/src/Editor/Api/McpTools/RecordInput/InputRecordingFileHelper.cs index a1fbf0b6d..dd05c3c88 100644 --- a/Packages/src/Editor/Api/McpTools/RecordInput/InputRecordingFileHelper.cs +++ b/Packages/src/Editor/Api/McpTools/RecordInput/InputRecordingFileHelper.cs @@ -1,3 +1,4 @@ +#if ULOOPMCP_HAS_INPUT_SYSTEM #nullable enable using System; using System.Collections.Generic; @@ -118,3 +119,4 @@ public static string ResolveLatestRecording(string inputPath) } } } +#endif diff --git a/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs b/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs index 96157e5d0..ec75408f1 100644 --- a/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using UnityEditor; using UnityEngine; +#if ULOOPMCP_HAS_INPUT_SYSTEM using UnityEngine.InputSystem; +#endif using Newtonsoft.Json; using Newtonsoft.Json.Serialization; @@ -17,12 +19,27 @@ public class RecordInputTool : AbstractUnityTool "record-input"; - protected override async Task ExecuteAsync( + protected override +#if !ULOOPMCP_HAS_INPUT_SYSTEM +#pragma warning disable CS1998 +#endif + async Task ExecuteAsync( RecordInputSchema parameters, CancellationToken ct) +#if !ULOOPMCP_HAS_INPUT_SYSTEM +#pragma warning restore CS1998 +#endif { ct.ThrowIfCancellationRequested(); +#if !ULOOPMCP_HAS_INPUT_SYSTEM + return new RecordInputResponse + { + Success = false, + Message = "record-input requires the Input System package (com.unity.inputsystem). Install it via Package Manager and set Active Input Handling to 'Input System Package (New)' or 'Both' in Player Settings.", + Action = parameters.Action.ToString() + }; +#else string correlationId = McpConstants.GenerateCorrelationId(); VibeLogger.LogInfo( @@ -56,6 +73,7 @@ protected override async Task ExecuteAsync( ); return response; +#endif } private static async Task ExecuteStartAsync(RecordInputSchema parameters, CancellationToken ct) diff --git a/Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs b/Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs index 8f816dfd5..6aa462253 100644 --- a/Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs +++ b/Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs @@ -1,3 +1,4 @@ +#if ULOOPMCP_HAS_INPUT_SYSTEM #nullable enable using System; using System.Collections.Generic; @@ -674,3 +675,4 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state) } } } +#endif diff --git a/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs b/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs index ec81ba746..9a1e04347 100644 --- a/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using UnityEditor; using UnityEngine; +#if ULOOPMCP_HAS_INPUT_SYSTEM using UnityEngine.InputSystem; +#endif using Newtonsoft.Json; using Newtonsoft.Json.Serialization; @@ -17,12 +19,27 @@ public class ReplayInputTool : AbstractUnityTool "replay-input"; - protected override async Task ExecuteAsync( + protected override +#if !ULOOPMCP_HAS_INPUT_SYSTEM +#pragma warning disable CS1998 +#endif + async Task ExecuteAsync( ReplayInputSchema parameters, CancellationToken ct) +#if !ULOOPMCP_HAS_INPUT_SYSTEM +#pragma warning restore CS1998 +#endif { ct.ThrowIfCancellationRequested(); +#if !ULOOPMCP_HAS_INPUT_SYSTEM + return new ReplayInputResponse + { + Success = false, + Message = "replay-input requires the Input System package (com.unity.inputsystem). Install it via Package Manager and set Active Input Handling to 'Input System Package (New)' or 'Both' in Player Settings.", + Action = parameters.Action.ToString() + }; +#else string correlationId = McpConstants.GenerateCorrelationId(); VibeLogger.LogInfo( @@ -61,6 +78,7 @@ protected override async Task ExecuteAsync( await Task.CompletedTask; return response; +#endif } private static ReplayInputResponse ExecuteStart(ReplayInputSchema parameters) diff --git a/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs b/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs index 37be870f4..97e7e55e0 100644 --- a/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs +++ b/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs @@ -312,6 +312,5 @@ private static bool CanInjectKeyboardState(Keyboard keyboard) { return EditorApplication.isPlaying && !EditorApplication.isPaused && Keyboard.current == keyboard; } -#endif } } diff --git a/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs b/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs index c1b81d208..a5c012b6a 100644 --- a/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs @@ -384,6 +384,5 @@ private static bool CanInjectMouseState(Mouse mouse) { return EditorApplication.isPlaying && !EditorApplication.isPaused && Mouse.current == mouse; } -#endif } } diff --git a/Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs b/Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs index 1308c429f..1dc598712 100644 --- a/Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs +++ b/Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs @@ -1,3 +1,4 @@ +#if ULOOPMCP_HAS_INPUT_SYSTEM using System; using System.Collections.Generic; using System.IO; @@ -378,3 +379,4 @@ private static void SetIndicatorClass(VisualElement indicator, string activeClas } } } +#endif diff --git a/Packages/src/README.md b/Packages/src/README.md index dedfa04c4..a36a6bc6b 100644 --- a/Packages/src/README.md +++ b/Packages/src/README.md @@ -72,6 +72,9 @@ Scope(s): io.github.hatayama.uloopmcp 3. Open Package Manager window and select OpenUPM in the My Registries section. Unity CLI Loop will be displayed. +> [!NOTE] +> `com.unity.inputsystem` is now an optional dependency. Install it only if you want Input System features such as `simulate-keyboard`, `simulate-mouse-input`, `record-input`, `replay-input`, and the Recordings window. + # Quickstart ## Step 1: Install the CLI @@ -468,7 +471,7 @@ Supports 6 actions: Click, LongPress, Drag (one-shot), DragStart/DragMove/DragEn https://github.com/user-attachments/assets/c7ee9103-c282-4f90-8b01-64bb17400f3e ### 13. simulate-mouse-input - Simulate Mouse Input in PlayMode via Input System -Simulate mouse input in PlayMode via Input System. Injects button clicks, mouse delta, and scroll wheel directly into `Mouse.current` for game logic that reads Input System. Unlike `simulate-mouse-ui` which fires EventSystem pointer events for uGUI, this tool targets game logic that reads `Mouse.current` directly. Requires the Input System package, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. +Simulate mouse input in PlayMode via Input System. Injects button clicks, mouse delta, and scroll wheel directly into `Mouse.current` for game logic that reads Input System. Unlike `simulate-mouse-ui` which fires EventSystem pointer events for uGUI, this tool targets game logic that reads `Mouse.current` directly. This tool is available only when the Input System package is installed, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Supports 5 actions: Click, LongPress, MoveDelta, SmoothDelta, Scroll. @@ -482,7 +485,7 @@ Supports 5 actions: Click, LongPress, MoveDelta, SmoothDelta, Scroll. ``` ### 14. simulate-keyboard - Simulate Keyboard Input in PlayMode -Simulate keyboard key input in PlayMode via Input System. Supports single key taps, sustained holds, and multi-key combinations (e.g. Shift+W for sprinting). Requires the Input System package, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Game code must read input via Input System API (e.g. `Keyboard.current[Key.W].isPressed`), not legacy `Input.GetKey()`. +Simulate keyboard key input in PlayMode via Input System. Supports single key taps, sustained holds, and multi-key combinations (e.g. Shift+W for sprinting). This tool is available only when the Input System package is installed, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Game code must read input via Input System API (e.g. `Keyboard.current[Key.W].isPressed`), not legacy `Input.GetKey()`. Supports 3 actions: Press (one-shot tap or timed hold), KeyDown (hold key down), KeyUp (release held key). @@ -497,7 +500,7 @@ Supports 3 actions: Press (one-shot tap or timed hold), KeyDown (hold key down), ``` ### 15. record-input - Record Input During PlayMode -Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. Captures key presses, mouse movement, clicks, and scroll events via Input System device state diffing. Requires the Input System package. +Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. Captures key presses, mouse movement, clicks, and scroll events via Input System device state diffing. This tool is available only when the Input System package is installed. ```text → record-input (Action: Start) @@ -507,7 +510,7 @@ Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. ``` ### 16. replay-input - Replay Recorded Input During PlayMode -Replay recorded keyboard and mouse input during PlayMode. Loads a JSON recording and injects input frame-by-frame via Input System. Supports looping and progress monitoring. Requires the Input System package. +Replay recorded keyboard and mouse input during PlayMode. Loads a JSON recording and injects input frame-by-frame via Input System. Supports looping and progress monitoring. This tool is available only when the Input System package is installed. ```text → replay-input (Action: Start) diff --git a/Packages/src/TOOL_REFERENCE_ja.md b/Packages/src/TOOL_REFERENCE_ja.md index 350b4c537..b285f18d9 100644 --- a/Packages/src/TOOL_REFERENCE_ja.md +++ b/Packages/src/TOOL_REFERENCE_ja.md @@ -245,7 +245,7 @@ - `EndPositionY` (number): 終了Y座標(Dragアクション用) ### 13. simulate-mouse-input -- **説明**: Input System経由でPlayMode中のマウス入力をシミュレーション。ボタンクリック、マウスデルタ、スクロールホイールを `Mouse.current` に直接注入。`wasPressedThisFrame`や`Mouse.current.delta`等を読むゲームロジック向け。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要がある。IPointerClickHandler等のUI要素には `simulate-mouse-ui` を使用 +- **説明**: Input System経由でPlayMode中のマウス入力をシミュレーション。ボタンクリック、マウスデルタ、スクロールホイールを `Mouse.current` に直接注入。`wasPressedThisFrame`や`Mouse.current.delta`等を読むゲームロジック向け。Input Systemパッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要がある。IPointerClickHandler等のUI要素には `simulate-mouse-ui` を使用 - **パラメータ**: - `Action` (enum): マウス入力アクション - "Click", "LongPress", "MoveDelta", "SmoothDelta", "Scroll"(デフォルト: "Click") - `Click`: ボタンのpress+releaseを注入し、`wasPressedThisFrame`がtrueを返すようにする @@ -270,7 +270,7 @@ - `PositionY` (number, nullable): 使用されたY座標(位置を使わないアクションではnull) ### 14. simulate-keyboard -- **説明**: Input System経由でPlayMode中のキーボード入力をシミュレーション。単発のキータップ、長押し、複数キーの同時押しに対応。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要がある。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には非対応 +- **説明**: Input System経由でPlayMode中のキーボード入力をシミュレーション。単発のキータップ、長押し、複数キーの同時押しに対応。Input Systemパッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要がある。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には非対応 - **パラメータ**: - `Action` (enum): キーボードアクション - "Press", "KeyDown", "KeyUp"(デフォルト: "Press") - `Press`: ワンショットキータップ(KeyDown→KeyUp)。`Duration`で長押し時間を指定可能 diff --git a/Packages/src/package.json b/Packages/src/package.json index 6d2be1894..127d85b12 100644 --- a/Packages/src/package.json +++ b/Packages/src/package.json @@ -12,7 +12,6 @@ "url": "https://github.com/hatayama/uLoopMCP" }, "dependencies": { - "com.unity.inputsystem": "1.14.2", "com.unity.ugui": "1.0.0", "com.unity.nuget.newtonsoft-json": "3.2.1" }, diff --git a/README.md b/README.md index dedfa04c4..a36a6bc6b 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ Scope(s): io.github.hatayama.uloopmcp 3. Open Package Manager window and select OpenUPM in the My Registries section. Unity CLI Loop will be displayed. +> [!NOTE] +> `com.unity.inputsystem` is now an optional dependency. Install it only if you want Input System features such as `simulate-keyboard`, `simulate-mouse-input`, `record-input`, `replay-input`, and the Recordings window. + # Quickstart ## Step 1: Install the CLI @@ -468,7 +471,7 @@ Supports 6 actions: Click, LongPress, Drag (one-shot), DragStart/DragMove/DragEn https://github.com/user-attachments/assets/c7ee9103-c282-4f90-8b01-64bb17400f3e ### 13. simulate-mouse-input - Simulate Mouse Input in PlayMode via Input System -Simulate mouse input in PlayMode via Input System. Injects button clicks, mouse delta, and scroll wheel directly into `Mouse.current` for game logic that reads Input System. Unlike `simulate-mouse-ui` which fires EventSystem pointer events for uGUI, this tool targets game logic that reads `Mouse.current` directly. Requires the Input System package, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. +Simulate mouse input in PlayMode via Input System. Injects button clicks, mouse delta, and scroll wheel directly into `Mouse.current` for game logic that reads Input System. Unlike `simulate-mouse-ui` which fires EventSystem pointer events for uGUI, this tool targets game logic that reads `Mouse.current` directly. This tool is available only when the Input System package is installed, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Supports 5 actions: Click, LongPress, MoveDelta, SmoothDelta, Scroll. @@ -482,7 +485,7 @@ Supports 5 actions: Click, LongPress, MoveDelta, SmoothDelta, Scroll. ``` ### 14. simulate-keyboard - Simulate Keyboard Input in PlayMode -Simulate keyboard key input in PlayMode via Input System. Supports single key taps, sustained holds, and multi-key combinations (e.g. Shift+W for sprinting). Requires the Input System package, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Game code must read input via Input System API (e.g. `Keyboard.current[Key.W].isPressed`), not legacy `Input.GetKey()`. +Simulate keyboard key input in PlayMode via Input System. Supports single key taps, sustained holds, and multi-key combinations (e.g. Shift+W for sprinting). This tool is available only when the Input System package is installed, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings. Game code must read input via Input System API (e.g. `Keyboard.current[Key.W].isPressed`), not legacy `Input.GetKey()`. Supports 3 actions: Press (one-shot tap or timed hold), KeyDown (hold key down), KeyUp (release held key). @@ -497,7 +500,7 @@ Supports 3 actions: Press (one-shot tap or timed hold), KeyDown (hold key down), ``` ### 15. record-input - Record Input During PlayMode -Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. Captures key presses, mouse movement, clicks, and scroll events via Input System device state diffing. Requires the Input System package. +Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. Captures key presses, mouse movement, clicks, and scroll events via Input System device state diffing. This tool is available only when the Input System package is installed. ```text → record-input (Action: Start) @@ -507,7 +510,7 @@ Record keyboard and mouse input during PlayMode frame-by-frame into a JSON file. ``` ### 16. replay-input - Replay Recorded Input During PlayMode -Replay recorded keyboard and mouse input during PlayMode. Loads a JSON recording and injects input frame-by-frame via Input System. Supports looping and progress monitoring. Requires the Input System package. +Replay recorded keyboard and mouse input during PlayMode. Loads a JSON recording and injects input frame-by-frame via Input System. Supports looping and progress monitoring. This tool is available only when the Input System package is installed. ```text → replay-input (Action: Start) diff --git a/README_ja.md b/README_ja.md index a6e634fb5..083e02309 100644 --- a/README_ja.md +++ b/README_ja.md @@ -72,6 +72,9 @@ Scope(s): io.github.hatayama.uloopmcp 3. Package Managerウィンドウを開き、My RegistriesセクションのOpenUPMを選択。Unity CLI Loopが表示されます。 +> [!NOTE] +> `com.unity.inputsystem` は optional dependency になりました。`simulate-keyboard`、`simulate-mouse-input`、`record-input`、`replay-input`、Recordings ウィンドウを使いたい場合だけ追加してください。 + # クイックスタート ## ステップ1: CLIのインストール @@ -466,7 +469,7 @@ PlayMode中のUI要素に対してマウスクリック・長押し・ドラッ https://github.com/user-attachments/assets/c7ee9103-c282-4f90-8b01-64bb17400f3e ### 13. simulate-mouse-input - Input System経由のPlayModeマウス入力シミュレーション -Input System経由でPlayMode中のマウス入力をシミュレーションします。ボタンクリック、マウスデルタ、スクロールホイールを`Mouse.current`に直接注入します。EventSystemのポインタイベントを発火する`simulate-mouse-ui`と異なり、`Mouse.current`を直接読み取るゲームロジック向けのツールです。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを`Input System Package (New)`または`Both`に設定する必要があります。 +Input System経由でPlayMode中のマウス入力をシミュレーションします。ボタンクリック、マウスデルタ、スクロールホイールを`Mouse.current`に直接注入します。EventSystemのポインタイベントを発火する`simulate-mouse-ui`と異なり、`Mouse.current`を直接読み取るゲームロジック向けのツールです。このツールは Input System パッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを`Input System Package (New)`または`Both`に設定する必要があります。 5つのアクションに対応: Click、LongPress、MoveDelta、SmoothDelta、Scroll @@ -480,7 +483,7 @@ Input System経由でPlayMode中のマウス入力をシミュレーションし ``` ### 14. simulate-keyboard - PlayModeでのキーボード入力シミュレーション -Input System経由でPlayMode中のキーボード入力をシミュレーションします。単発のキータップ、長押し、複数キーの同時押し(例:Shift+Wでスプリント)に対応しています。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要があります。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には対応していません。 +Input System経由でPlayMode中のキーボード入力をシミュレーションします。単発のキータップ、長押し、複数キーの同時押し(例:Shift+Wでスプリント)に対応しています。このツールは Input System パッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要があります。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には対応していません。 3つのアクションに対応: Press(ワンショットタップまたは時間指定ホールド)、KeyDown(キーを押し続ける)、KeyUp(押下中のキーを解放) @@ -495,7 +498,7 @@ Input System経由でPlayMode中のキーボード入力をシミュレーショ ``` ### 15. record-input - PlayMode中の入力記録 -PlayMode中のキーボード・マウス入力をフレーム単位でJSONファイルに記録します。Input Systemのデバイス状態差分によりキー押下、マウス移動、クリック、スクロールイベントをキャプチャします。Input Systemパッケージが必要です。 +PlayMode中のキーボード・マウス入力をフレーム単位でJSONファイルに記録します。Input Systemのデバイス状態差分によりキー押下、マウス移動、クリック、スクロールイベントをキャプチャします。このツールは Input System パッケージ導入時のみ利用可能です。 ```text → record-input (Action: Start) @@ -505,7 +508,7 @@ PlayMode中のキーボード・マウス入力をフレーム単位でJSONフ ``` ### 16. replay-input - 記録された入力のPlayMode再生 -記録されたキーボード・マウス入力をPlayMode中に再生します。JSON記録を読み込み、Input System経由でフレーム単位で入力を注入します。ループ再生と進捗モニタリングに対応しています。Input Systemパッケージが必要です。 +記録されたキーボード・マウス入力をPlayMode中に再生します。JSON記録を読み込み、Input System経由でフレーム単位で入力を注入します。ループ再生と進捗モニタリングに対応しています。このツールは Input System パッケージ導入時のみ利用可能です。 ```text → replay-input (Action: Start) From 8c3e8287fba26d8a98ad67baf0e9bd34a23a56ac Mon Sep 17 00:00:00 2001 From: hatayama Date: Wed, 15 Apr 2026 17:15:08 +0900 Subject: [PATCH 2/4] Fix Input System preprocessor blocks --- .../Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs | 1 + .../Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs b/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs index 97e7e55e0..37be870f4 100644 --- a/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs +++ b/Packages/src/Editor/Api/McpTools/SimulateKeyboard/SimulateKeyboardTool.cs @@ -312,5 +312,6 @@ private static bool CanInjectKeyboardState(Keyboard keyboard) { return EditorApplication.isPlaying && !EditorApplication.isPaused && Keyboard.current == keyboard; } +#endif } } diff --git a/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs b/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs index a5c012b6a..c1b81d208 100644 --- a/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/SimulateMouseInput/SimulateMouseInputTool.cs @@ -384,5 +384,6 @@ private static bool CanInjectMouseState(Mouse mouse) { return EditorApplication.isPlaying && !EditorApplication.isPaused && Mouse.current == mouse; } +#endif } } From 63dd43c5285b27e1102b024fe8512e3cc11cf2e1 Mon Sep 17 00:00:00 2001 From: hatayama Date: Wed, 15 Apr 2026 17:17:26 +0900 Subject: [PATCH 3/4] Guard Input System-only tool implementations --- .../src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs | 3 ++- .../src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs b/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs index ec75408f1..6ac49539d 100644 --- a/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs @@ -76,6 +76,7 @@ async Task ExecuteAsync( #endif } +#if ULOOPMCP_HAS_INPUT_SYSTEM private static async Task ExecuteStartAsync(RecordInputSchema parameters, CancellationToken ct) { if (!EditorApplication.isPlaying) @@ -246,6 +247,6 @@ private static RecordInputResponse ExecuteStop(RecordInputSchema parameters) DurationSeconds = data.Metadata.DurationSeconds }; } - +#endif } } diff --git a/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs b/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs index 9a1e04347..fc813b29b 100644 --- a/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs +++ b/Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs @@ -81,6 +81,7 @@ async Task ExecuteAsync( #endif } +#if ULOOPMCP_HAS_INPUT_SYSTEM private static ReplayInputResponse ExecuteStart(ReplayInputSchema parameters) { if (!EditorApplication.isPlaying) @@ -225,6 +226,6 @@ private static ReplayInputResponse ExecuteStatus() IsReplaying = true }; } - +#endif } } From 0c32f448d83b3a4892e0b9b0ec47797eb3ed00c6 Mon Sep 17 00:00:00 2001 From: hatayama Date: Wed, 15 Apr 2026 18:25:45 +0900 Subject: [PATCH 4/4] Sync packaged Japanese README --- Packages/src/README_ja.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Packages/src/README_ja.md b/Packages/src/README_ja.md index a6e634fb5..083e02309 100644 --- a/Packages/src/README_ja.md +++ b/Packages/src/README_ja.md @@ -72,6 +72,9 @@ Scope(s): io.github.hatayama.uloopmcp 3. Package Managerウィンドウを開き、My RegistriesセクションのOpenUPMを選択。Unity CLI Loopが表示されます。 +> [!NOTE] +> `com.unity.inputsystem` は optional dependency になりました。`simulate-keyboard`、`simulate-mouse-input`、`record-input`、`replay-input`、Recordings ウィンドウを使いたい場合だけ追加してください。 + # クイックスタート ## ステップ1: CLIのインストール @@ -466,7 +469,7 @@ PlayMode中のUI要素に対してマウスクリック・長押し・ドラッ https://github.com/user-attachments/assets/c7ee9103-c282-4f90-8b01-64bb17400f3e ### 13. simulate-mouse-input - Input System経由のPlayModeマウス入力シミュレーション -Input System経由でPlayMode中のマウス入力をシミュレーションします。ボタンクリック、マウスデルタ、スクロールホイールを`Mouse.current`に直接注入します。EventSystemのポインタイベントを発火する`simulate-mouse-ui`と異なり、`Mouse.current`を直接読み取るゲームロジック向けのツールです。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを`Input System Package (New)`または`Both`に設定する必要があります。 +Input System経由でPlayMode中のマウス入力をシミュレーションします。ボタンクリック、マウスデルタ、スクロールホイールを`Mouse.current`に直接注入します。EventSystemのポインタイベントを発火する`simulate-mouse-ui`と異なり、`Mouse.current`を直接読み取るゲームロジック向けのツールです。このツールは Input System パッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを`Input System Package (New)`または`Both`に設定する必要があります。 5つのアクションに対応: Click、LongPress、MoveDelta、SmoothDelta、Scroll @@ -480,7 +483,7 @@ Input System経由でPlayMode中のマウス入力をシミュレーションし ``` ### 14. simulate-keyboard - PlayModeでのキーボード入力シミュレーション -Input System経由でPlayMode中のキーボード入力をシミュレーションします。単発のキータップ、長押し、複数キーの同時押し(例:Shift+Wでスプリント)に対応しています。Input Systemパッケージが必要で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要があります。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には対応していません。 +Input System経由でPlayMode中のキーボード入力をシミュレーションします。単発のキータップ、長押し、複数キーの同時押し(例:Shift+Wでスプリント)に対応しています。このツールは Input System パッケージ導入時のみ利用可能で、Player SettingsのActive Input Handlingを `Input System Package (New)` または `Both` に設定する必要があります。ゲームコードがInput System API(例: `Keyboard.current[Key.W].isPressed`)で入力を読み取っている必要があり、レガシーの `Input.GetKey()` には対応していません。 3つのアクションに対応: Press(ワンショットタップまたは時間指定ホールド)、KeyDown(キーを押し続ける)、KeyUp(押下中のキーを解放) @@ -495,7 +498,7 @@ Input System経由でPlayMode中のキーボード入力をシミュレーショ ``` ### 15. record-input - PlayMode中の入力記録 -PlayMode中のキーボード・マウス入力をフレーム単位でJSONファイルに記録します。Input Systemのデバイス状態差分によりキー押下、マウス移動、クリック、スクロールイベントをキャプチャします。Input Systemパッケージが必要です。 +PlayMode中のキーボード・マウス入力をフレーム単位でJSONファイルに記録します。Input Systemのデバイス状態差分によりキー押下、マウス移動、クリック、スクロールイベントをキャプチャします。このツールは Input System パッケージ導入時のみ利用可能です。 ```text → record-input (Action: Start) @@ -505,7 +508,7 @@ PlayMode中のキーボード・マウス入力をフレーム単位でJSONフ ``` ### 16. replay-input - 記録された入力のPlayMode再生 -記録されたキーボード・マウス入力をPlayMode中に再生します。JSON記録を読み込み、Input System経由でフレーム単位で入力を注入します。ループ再生と進捗モニタリングに対応しています。Input Systemパッケージが必要です。 +記録されたキーボード・マウス入力をPlayMode中に再生します。JSON記録を読み込み、Input System経由でフレーム単位で入力を注入します。ループ再生と進捗モニタリングに対応しています。このツールは Input System パッケージ導入時のみ利用可能です。 ```text → replay-input (Action: Start)