一键导入
uloop-record-input
// Record keyboard and mouse input during PlayMode into a JSON file. Use when you need to: (1) Capture human gameplay input for later replay, (2) Record input sequences for E2E testing, (3) Save input for bug reproduction.
// Record keyboard and mouse input during PlayMode into a JSON file. Use when you need to: (1) Capture human gameplay input for later replay, (2) Record input sequences for E2E testing, (3) Save input for bug reproduction.
| name | uloop-record-input |
| description | Record keyboard and mouse input during PlayMode into a JSON file. Use when you need to: (1) Capture human gameplay input for later replay, (2) Record input sequences for E2E testing, (3) Save input for bug reproduction. |
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.
# Start recording
uloop record-input --action Start
# Start recording with key filter
uloop record-input --action Start --keys "W,A,S,D,Space"
# Stop recording and save
uloop record-input --action Stop
# Stop and save to specific path
uloop record-input --action Stop --output-path scripts/my-play.json
| Parameter | Type | Default | Description |
|---|---|---|---|
--action | enum | Start | Start - begin recording, Stop - stop and save |
--output-path | string | auto | Save path. Auto-generates under .uloop/outputs/InputRecordings/ |
--keys | string | "" | Comma-separated key filter. Empty = all common game keys |
Replay injects input frame-by-frame, so the game must produce identical results given identical input on each run. The following patterns break determinism and must be avoided in replay-targeted code:
| Avoid | Use Instead | Why |
|---|---|---|
Time.deltaTime for movement | Fixed per-frame constant (e.g. MOVE_SPEED = 0.1f) | deltaTime varies between runs even at the same target frame rate |
Random.Range() / UnityEngine.Random | Seeded random (new System.Random(fixedSeed)) or remove randomness | Different random sequence each run |
Rigidbody / Physics simulation | Kinematic movement via Transform.Translate | Physics is non-deterministic across runs |
WaitForSeconds(n) in coroutines | WaitForEndOfFrame or frame counting | Real-time waits depend on frame timing |
Time.time / Time.realtimeSinceStartup | Frame counter (Time.frameCount - startFrame) | Time values drift between runs |
FindObjectsOfType without sort | FindObjectsByType(FindObjectsSortMode.InstanceID) | Iteration order is non-deterministic |
async/await with Task.Delay | Frame-based waiting | Real-time delays are non-deterministic |
Set Application.targetFrameRate = 60 (or your target) to reduce frame timing variance. See InputReplayVerificationController for a complete example of deterministic game logic.
com.unity.inputsystem)Input System Package (New) or Both in Player SettingsReturns JSON with:
Success: Whether the operation succeededMessage: Status messageOutputPath: Path to saved recording (Stop only)TotalFrames: Number of frames recorded (Stop only)DurationSeconds: Recording duration in seconds (Stop only)Execute C# code dynamically in Unity Editor. Use when you need to: (1) Wire prefab/material references and AddComponent operations, (2) Edit SerializedObject properties and reference wiring, (3) Perform scene/hierarchy edits and batch operations, (4) PlayMode automation (click buttons, raycast, invoke methods), (5) PlayMode UI controls (InputField, Slider, Toggle, Dropdown), (6) PlayMode inspection (scene info, reflection, physics state). NOT for file I/O or script authoring.
Execute Unity Editor menu commands programmatically. Use when you need to: (1) Trigger menu commands like save, build, or refresh, (2) Automate editor actions via menu paths, (3) Run custom menu items defined in project scripts.
Replay recorded input during PlayMode with frame-precise injection. Use when you need to: (1) Reproduce recorded gameplay exactly, (2) Run E2E tests from recorded input, (3) Generate demo videos with consistent input.
Capture screenshots of Unity Editor windows as PNG files. Use when you need to: (1) Screenshot Game View, Scene View, Console, Inspector, or other windows, (2) Capture current visual state for debugging or documentation, (3) Save editor window appearance as image files.
Simulate keyboard key input in PlayMode via Input System. Use when you need to: (1) Press game control keys like WASD, Space, or Shift during PlayMode, (2) Hold keys down for continuous movement or actions, (3) Combine multiple held keys for complex input like Shift+W for sprint.
Simulate mouse input in PlayMode via Input System. Injects button clicks, mouse delta, and scroll wheel directly into Mouse.current. Use when you need to: (1) Click in games that read Mouse.current.leftButton.wasPressedThisFrame, (2) Right-click for actions like block placement, (3) Inject mouse delta for FPS camera control, (4) Inject scroll wheel for hotbar switching or zoom. For UI elements with IPointerClickHandler, use simulate-mouse-ui instead.