Skip to content

fix: allow installation without the new Input System package#938

Merged
hatayama merged 4 commits into
mainfrom
feature/hatayama/make-inputsystem-optional
Apr 15, 2026
Merged

fix: allow installation without the new Input System package#938
hatayama merged 4 commits into
mainfrom
feature/hatayama/make-inputsystem-optional

Conversation

@hatayama
Copy link
Copy Markdown
Owner

@hatayama hatayama commented Apr 15, 2026

Summary

  • make com.unity.inputsystem optional for package consumers
  • keep the Input System tools discoverable and return actionable guidance when the package is missing
  • compile the Recordings window only when Input System support is available

Changes

  • remove the hard com.unity.inputsystem dependency from the package manifest and lockfile
  • guard Input System-only implementations behind ULOOPMCP_HAS_INPUT_SYSTEM
  • keep simulate-keyboard, simulate-mouse-input, record-input, and replay-input registered with clear error messages when Input System is not installed
  • update the README and tool reference docs to explain the optional dependency behavior

Verification

  • uloop compile --force-recompile true --wait-for-domain-reload true
  • uloop get-logs --log-type Error --max-count 20
  • uloop get-logs --log-type Warning --max-count 20
  • uloop simulate-keyboard --action Press --key W
  • uloop simulate-mouse-input --action Click --x 10 --y 10
  • uloop record-input --action Start
  • uloop replay-input --action Status
  • codex-review-loop finished with no actionable findings

Overview

This pull request makes the com.unity.inputsystem package an optional dependency for the uLoopMCP package. The Input System–dependent tools remain registered and discoverable, but emit clear error messages when the Input System package is not installed. All Input System–specific code is conditionally compiled behind the ULOOPMCP_HAS_INPUT_SYSTEM preprocessor symbol.

Key Changes

Dependency Management

  • Removed com.unity.inputsystem (version 1.14.2) from both package.json and packages-lock.json
  • The package now has only two required dependencies: com.unity.ugui and com.unity.nuget.newtonsoft-json

Conditional Compilation Architecture

The following Input System–dependent classes are now wrapped in #if ULOOPMCP_HAS_INPUT_SYSTEM ... #endif blocks:

RecordInputTool
├── InputRecorder
├── InputRecordingFileHelper
└── ExecuteAsync() [with fallback error response]

ReplayInputTool
├── InputReplayer
└── ExecuteAsync() [with fallback error response]

RecordingsEditorWindow

Tool Implementation Changes

RecordInputTool.cs

  • ExecuteAsync() now provides dual behavior:
    • When ULOOPMCP_HAS_INPUT_SYSTEM is defined: Original logic executes (correlation ID generation, logging, action dispatch, response computation)
    • When undefined: Returns a RecordInputResponse with Success = false and an installation/configuration message
  • ExecuteStartAsync() helper wrapped in preprocessor guard
  • Tool remains registered but fails gracefully without Input System

ReplayInputTool.cs

  • Similar dual-behavior pattern in ExecuteAsync()
  • ExecuteStart() helper conditionally compiled
  • Returns ReplayInputResponse with configuration guidance when Input System is unavailable
  • Maintains UI responsiveness with clear error feedback

InputRecorder.cs, InputRecordingFileHelper.cs, InputReplayer.cs

  • File-level conditional compilation with no internal logic changes
  • Classes completely omitted from builds when ULOOPMCP_HAS_INPUT_SYSTEM is not defined

RecordingsEditorWindow.cs

  • Entire window UI conditionally compiled
  • Only available when Input System support is present

Documentation Updates

English Documentation (README.md and Packages/src/README.md)

  • Added installation notes explaining com.unity.inputsystem is optional
  • Updated simulate-keyboard, simulate-mouse-input, record-input, and replay-input documentation
  • Changed phrasing from "Requires the Input System package" to "available only when the Input System package is installed"
  • Retained Active Input Handling requirement details

Japanese Documentation (README_ja.md and TOOL_REFERENCE_ja.md)

  • Added NOTE indicating com.unity.inputsystem is optional
  • Updated tool descriptions (simulate-mouse-input, simulate-keyboard, record-input, replay-input)
  • Changed from "Input Systemパッケージが必要" to "Input Systemパッケージ導入時のみ利用可能"
  • Maintained all configuration requirements and usage notes

Impact Analysis

When Input System is Present (ULOOPMCP_HAS_INPUT_SYSTEM defined)

  • All functionality remains unchanged
  • Tool behavior is identical to previous implementation
  • Recordings window UI is available

When Input System is Absent (ULOOPMCP_HAS_INPUT_SYSTEM undefined)

  • Tools remain discoverable and executable
  • Input System–dependent tools (simulate-keyboard, simulate-mouse-input, record-input, replay-input) emit actionable error messages with installation guidance
  • Recordings window is not compiled
  • Recording and replay operations fail gracefully with user-facing guidance

Build Configuration

The preprocessor symbol ULOOPMCP_HAS_INPUT_SYSTEM is automatically defined when com.unity.inputsystem package is present in the project, enabling automatic conditional compilation based on package availability.

Testing Verification

Per the PR description, the following verification was performed:

  • Recompilation with forced recompile and domain reload
  • Error and warning log review
  • Tool exercise (simulate-keyboard, simulate-mouse-input, record-input, replay-input with various actions)
  • codex-review-loop validation completed with no actionable findings

Summary by cubic

Make the Unity Input System optional so uLoop works without com.unity.inputsystem. Input tools stay visible and show clear guidance if the package is missing; the Recordings window and Input System classes only compile when the package is present.

  • New Features

    • Removed hard dependency on com.unity.inputsystem from package.json and the lockfile.
    • Wrapped Input System code in ULOOPMCP_HAS_INPUT_SYSTEM (InputRecorder, InputRecordingFileHelper, InputReplayer, RecordingsEditorWindow; guarded imports in record-input/replay-input with helpful fallback messages).
    • Updated docs to note the optional dependency and synced English/Japanese READMEs (including Packages/src/README_ja.md) and JP tool references.
  • Migration

    • No changes if you don’t use Input System features.
    • To enable input tools and the Recordings window: install com.unity.inputsystem and set Active Input Handling to “Input System Package (New)” or “Both”.

Written for commit 0c32f44. Summary will update on new commits.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

This PR makes com.unity.inputsystem an optional dependency by removing it from package manifests, wrapping Input System-dependent code with ULOOPMCP_HAS_INPUT_SYSTEM preprocessor directives, and updating documentation to reflect the conditional availability of Input System features.

Changes

Cohort / File(s) Summary
Dependency Declarations
Packages/packages-lock.json, Packages/src/package.json
Removed com.unity.inputsystem (v1.14.2) from dependency lists.
Input Recording Code
Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs, InputRecordingFileHelper.cs, RecordInputTool.cs
Wrapped Input System dependencies with #if ULOOPMCP_HAS_INPUT_SYSTEM preprocessor guards. RecordInputTool.ExecuteAsync now includes fallback behavior when Input System is unavailable, returning a failure response with diagnostic message.
Input Replay Code
Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs, ReplayInputTool.cs
Wrapped Input System dependencies with #if ULOOPMCP_HAS_INPUT_SYSTEM preprocessor guards. ReplayInputTool.ExecuteAsync includes fallback that returns failure when Input System is unavailable.
Recordings UI
Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs
Wrapped entire file with #if ULOOPMCP_HAS_INPUT_SYSTEM to conditionally compile the editor window.
Documentation (English)
Packages/src/README.md, README.md
Updated tool documentation to replace "Requires Input System package" phrasing with "available only when the Input System package is installed" and added notes clarifying the optional dependency status.
Documentation (Japanese)
Packages/src/TOOL_REFERENCE_ja.md, README_ja.md
Updated Japanese documentation with equivalent phrasing changes and optional dependency notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main objective: making Input System an optional package dependency rather than a hard requirement.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/hatayama/make-inputsystem-optional

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hatayama hatayama changed the title feat: allow latest uLoop updates without installing Input System feat: allow latest updates without installing Input System Apr 15, 2026
@hatayama hatayama changed the title feat: allow latest updates without installing Input System fix: prevent errors when the new Input System is not installed Apr 15, 2026
@hatayama hatayama changed the title fix: prevent errors when the new Input System is not installed fix: allow installation without the new Input System package Apr 15, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

503-513: ⚠️ Potential issue | 🟡 Minor

Add the Active Input Handling requirement here too.

record-input / replay-input now only mention package installation, but the tool-side guidance also requires Active Input Handling to be Input System Package (New) or Both. Without that note, users can end up with “installed but still not working” setups.

Suggested doc tweak
-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.
+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, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings.

-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.
+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, and Active Input Handling must be set to `Input System Package (New)` or `Both` in Player Settings.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 503 - 513, Update the documentation for the
"record-input" and "replay-input" sections to also require Unity's Active Input
Handling to be set to "Input System Package (New)" or "Both"; specifically,
amend the paragraphs that currently only mention the Input System package
installation (the lines describing record-input and replay-input) to add a short
note stating that even with the package installed the tools will not work unless
Active Input Handling is configured to "Input System Package (New)" or "Both" in
Player Settings, and include the exact terms "record-input", "replay-input", and
"Active Input Handling" so users can find the setting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@README.md`:
- Around line 503-513: Update the documentation for the "record-input" and
"replay-input" sections to also require Unity's Active Input Handling to be set
to "Input System Package (New)" or "Both"; specifically, amend the paragraphs
that currently only mention the Input System package installation (the lines
describing record-input and replay-input) to add a short note stating that even
with the package installed the tools will not work unless Active Input Handling
is configured to "Input System Package (New)" or "Both" in Player Settings, and
include the exact terms "record-input", "replay-input", and "Active Input
Handling" so users can find the setting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 24c483e9-4b7e-4277-b02d-4228fb10e916

📥 Commits

Reviewing files that changed from the base of the PR and between 6a814fe and 63dd43c.

⛔ Files ignored due to path filters (1)
  • Assets/Tests/PlayMode/uLoopMCP.Tests.PlayMode.asmdef is excluded by none and included by none
📒 Files selected for processing (12)
  • Packages/packages-lock.json
  • Packages/src/Editor/Api/McpTools/RecordInput/InputRecorder.cs
  • Packages/src/Editor/Api/McpTools/RecordInput/InputRecordingFileHelper.cs
  • Packages/src/Editor/Api/McpTools/RecordInput/RecordInputTool.cs
  • Packages/src/Editor/Api/McpTools/ReplayInput/InputReplayer.cs
  • Packages/src/Editor/Api/McpTools/ReplayInput/ReplayInputTool.cs
  • Packages/src/Editor/UI/Recordings/RecordingsEditorWindow.cs
  • Packages/src/README.md
  • Packages/src/TOOL_REFERENCE_ja.md
  • Packages/src/package.json
  • README.md
  • README_ja.md
💤 Files with no reviewable changes (2)
  • Packages/src/package.json
  • Packages/packages-lock.json

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="README_ja.md">

<violation number="1" location="README_ja.md:76">
P1: `com.unity.inputsystem` を optional dependency と案内する記述は、Input System を必須依存として扱うプロジェクト方針と矛盾しています。必須依存として案内してください。

(Based on your team's feedback about requiring com.unity.inputsystem as a hard dependency.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread README_ja.md
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 ウィンドウを使いたい場合だけ追加してください。
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: com.unity.inputsystem を optional dependency と案内する記述は、Input System を必須依存として扱うプロジェクト方針と矛盾しています。必須依存として案内してください。

(Based on your team's feedback about requiring com.unity.inputsystem as a hard dependency.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README_ja.md, line 76:

<comment>`com.unity.inputsystem` を optional dependency と案内する記述は、Input System を必須依存として扱うプロジェクト方針と矛盾しています。必須依存として案内してください。

(Based on your team's feedback about requiring com.unity.inputsystem as a hard dependency.) </comment>

<file context>
@@ -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 ウィンドウを使いたい場合だけ追加してください。
+
 # クイックスタート
</file context>
Suggested change
> `com.unity.inputsystem` は optional dependency になりました`simulate-keyboard``simulate-mouse-input``record-input``replay-input`、Recordings ウィンドウを使いたい場合だけ追加してください
> `com.unity.inputsystem` は必須依存です`simulate-keyboard``simulate-mouse-input``record-input``replay-input`、Recordings ウィンドウなどの機能を利用するため、プロジェクトに追加した状態を維持してください
Fix with Cubic

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

I did not apply this suggestion.

This PR intentionally makes com.unity.inputsystem optional at the package level by removing it from Packages/src/package.json (HEAD 63dd43c).
The README note is describing package installation, not the prerequisites for every Input System-based tool.

The tool-specific requirements still remain in the runtime error messages and skill docs for simulate-keyboard, simulate-mouse-input, record-input, and replay-input, so projects that want those features still need the Input System package installed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've updated an existing learning with this new information.

@hatayama hatayama merged commit b08d899 into main Apr 15, 2026
11 checks passed
@hatayama hatayama deleted the feature/hatayama/make-inputsystem-optional branch April 15, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant