Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
}
],
"noEngineReferences": false
}
}
1 change: 0 additions & 1 deletion Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 2 additions & 0 deletions Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if ULOOPMCP_HAS_INPUT_SYSTEM
#nullable enable
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -476,3 +477,4 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if ULOOPMCP_HAS_INPUT_SYSTEM
#nullable enable
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -118,3 +119,4 @@ public static string ResolveLatestRecording(string inputPath)
}
}
}
#endif
23 changes: 21 additions & 2 deletions Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,12 +19,27 @@ public class RecordInputTool : AbstractUnityTool<RecordInputSchema, RecordInputR
{
public override string ToolName => "record-input";

protected override async Task<RecordInputResponse> ExecuteAsync(
protected override
#if !ULOOPMCP_HAS_INPUT_SYSTEM
#pragma warning disable CS1998
#endif
async Task<RecordInputResponse> 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(
Expand Down Expand Up @@ -56,8 +73,10 @@ protected override async Task<RecordInputResponse> ExecuteAsync(
);

return response;
#endif
}

#if ULOOPMCP_HAS_INPUT_SYSTEM
private static async Task<RecordInputResponse> ExecuteStartAsync(RecordInputSchema parameters, CancellationToken ct)
{
if (!EditorApplication.isPlaying)
Expand Down Expand Up @@ -228,6 +247,6 @@ private static RecordInputResponse ExecuteStop(RecordInputSchema parameters)
DurationSeconds = data.Metadata.DurationSeconds
};
}

#endif
}
}
2 changes: 2 additions & 0 deletions Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if ULOOPMCP_HAS_INPUT_SYSTEM
#nullable enable
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -674,3 +675,4 @@ private static void OnPlayModeStateChanged(PlayModeStateChange state)
}
}
}
#endif
23 changes: 21 additions & 2 deletions Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,12 +19,27 @@ public class ReplayInputTool : AbstractUnityTool<ReplayInputSchema, ReplayInputR
{
public override string ToolName => "replay-input";

protected override async Task<ReplayInputResponse> ExecuteAsync(
protected override
#if !ULOOPMCP_HAS_INPUT_SYSTEM
#pragma warning disable CS1998
#endif
async Task<ReplayInputResponse> 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(
Expand Down Expand Up @@ -61,8 +78,10 @@ protected override async Task<ReplayInputResponse> ExecuteAsync(

await Task.CompletedTask;
return response;
#endif
}

#if ULOOPMCP_HAS_INPUT_SYSTEM
private static ReplayInputResponse ExecuteStart(ReplayInputSchema parameters)
{
if (!EditorApplication.isPlaying)
Expand Down Expand Up @@ -207,6 +226,6 @@ private static ReplayInputResponse ExecuteStatus()
IsReplaying = true
};
}

#endif
}
}
2 changes: 2 additions & 0 deletions Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if ULOOPMCP_HAS_INPUT_SYSTEM
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -378,3 +379,4 @@ private static void SetIndicatorClass(VisualElement indicator, string activeClas
}
}
}
#endif
11 changes: 7 additions & 4 deletions Packages/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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).

Expand All @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions Packages/src/README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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のインストール
Expand Down Expand Up @@ -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

Expand All @@ -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(押下中のキーを解放)

Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Packages/src/TOOL_REFERENCE_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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を返すようにする
Expand All @@ -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`で長押し時間を指定可能
Expand Down
1 change: 0 additions & 1 deletion Packages/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Loading
Loading