Skip to content

Conversation

@dsarno
Copy link
Collaborator

@dsarno dsarno commented Jan 19, 2026

Summary

  • Fixes test Modify_SetActive_ActivatesObject which was failing after the Prefab Stage PR
  • When trying to activate an inactive GameObject via manage_gameobject modify with setActive=true, the lookup would fail because inactive objects were not included in the search by default

Changes

  • GameObjectModify.cs: Automatically sets searchInactive=true when setActive=true is specified, allowing inactive objects to be found and activated

Test plan

  • Modify_SetActive_ActivatesObject test passes
  • All 20 ManageGameObjectModifyTests pass
  • Full EditMode test suite (262 tests) passes with no regressions

Summary by Sourcery

Ensure GameObject modify operations can activate inactive objects by including them in lookup when setActive is requested.

Bug Fixes:

  • Fix failure to locate inactive GameObjects when performing a modify operation with setActive=true, allowing them to be activated as intended.

Tests:

  • Verify Modify_SetActive_ActivatesObject and the full ManageGameObjectModify test suite pass, along with the broader EditMode tests.

Summary by CodeRabbit

  • Bug Fixes
    • Improved game object search functionality to properly detect and modify inactive objects when needed.

✏️ Tip: You can customize this high-level summary in your review settings.

When trying to activate an inactive GameObject via manage_gameobject modify with setActive=true, the lookup would fail because inactive objects were not included in the search by default.

Now automatically sets searchInactive=true when setActive=true is specified, allowing inactive objects to be found and activated.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates GameObjectModify to ensure inactive GameObjects can be found and activated by automatically enabling inactive-object search when setActive=true in modify requests.

Sequence diagram for modify with setActive=true searching inactive GameObjects

sequenceDiagram
    actor EditorUser
    participant ManageGameObjectModify as GameObjectModify
    participant ManageGameObjectCommon
    participant UnityEngine as GameObject

    EditorUser->>ManageGameObjectModify: Handle(params with setActive=true, targetToken, searchMethod)
    ManageGameObjectModify->>ManageGameObjectModify: Check params.setActive == true
    ManageGameObjectModify->>ManageGameObjectModify: Create findParams with searchInactive=true
    ManageGameObjectModify->>ManageGameObjectCommon: FindObjectInternal(targetToken, searchMethod, findParams)
    ManageGameObjectCommon-->>ManageGameObjectModify: targetGo (may be inactive)
    ManageGameObjectModify->>GameObject: SetActive(true)
    ManageGameObjectModify-->>EditorUser: Success or ErrorResponse
Loading

Class diagram for updated GameObjectModify inactive search behavior

classDiagram
    class GameObjectModify {
        <<static>>
        +Handle(JObject params, JToken targetToken, string searchMethod) object
    }

    class ManageGameObjectCommon {
        <<static>>
        +FindObjectInternal(JToken targetToken, string searchMethod, JObject findParams) GameObject
    }

    class JObject
    class JToken
    class GameObject {
        +SetActive(bool isActive) void
    }

    GameObjectModify ..> ManageGameObjectCommon : uses
    GameObjectModify ..> JObject : uses
    GameObjectModify ..> JToken : uses
    ManageGameObjectCommon ..> JToken : uses
    ManageGameObjectCommon ..> JObject : uses
    GameObjectModify ..> GameObject : activates via SetActive
Loading

File-Level Changes

Change Details Files
Ensure modify operations that setActive=true can find and activate inactive GameObjects.
  • Introduce optional findParams JObject that is conditionally populated when setActive=true is requested.
  • Automatically set searchInactive=true in findParams when setActive=true is specified in the modify parameters.
  • Pass the new findParams argument through to ManageGameObjectCommon.FindObjectInternal so inactive targets are included in the search.
  • Preserve existing error handling when the target GameObject cannot be found.
MCPForUnity/Editor/Tools/GameObjects/GameObjectModify.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The change augments GameObjectModify.cs to enable searching for inactive objects when setActive is true. A findParams object is introduced and passed to FindObjectInternal as an additional parameter, extending the method signature from two to three parameters.

Changes

Cohort / File(s) Summary
GameObject Search Enhancement
MCPForUnity/Editor/Tools/GameObjects/GameObjectModify.cs
Updated FindObjectInternal invocation to include findParams parameter for inactive object lookup when setActive is requested; method signature changed from 2 to 3 parameters (+9/-1)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hopping through objects both seen and unseen,
We search every corner, both active and lean,
With params in hand, we unlock the way,
To find what was sleeping, now ready to play!

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@sourcery-ai sourcery-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.

Hey - I've left some high level feedback:

  • Currently findParams is always set to {"searchInactive": true} when setActive == true, which will override any existing searchInactive preference; consider merging with or respecting @params["searchInactive"] so callers can still explicitly control this behavior.
  • Instead of creating a new JObject solely for searchInactive, you might pass @params (or a shallow clone) into FindObjectInternal and conditionally set searchInactive on it, which would avoid losing other potential lookup-related parameters.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Currently `findParams` is always set to `{"searchInactive": true}` when `setActive == true`, which will override any existing `searchInactive` preference; consider merging with or respecting `@params["searchInactive"]` so callers can still explicitly control this behavior.
- Instead of creating a new `JObject` solely for `searchInactive`, you might pass `@params` (or a shallow clone) into `FindObjectInternal` and conditionally set `searchInactive` on it, which would avoid losing other potential lookup-related parameters.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dsarno dsarno merged commit 8252e6d into CoplayDev:main Jan 19, 2026
1 of 2 checks passed
vbucc added a commit to Studio-Pronto/unity-mcp that referenced this pull request Jan 19, 2026
Upstream changes (v9.0.7 → v9.0.8):
- fix: UIDocument serialization to prevent infinite loops (CoplayDev#586)
- fix: Filter isCompiling false positives in Play mode (CoplayDev#582)
- fix: search inactive objects when setActive=true (CoplayDev#581)
- fix: Add Prefab Stage support for GameObject lookup (CoplayDev#573)
- fix: Prevent infinite compilation loop in Unity 6 (CoplayDev#559)
- fix: parse and validate read_console types (CoplayDev#565)
- fix: Local HTTP server UI check (CoplayDev#556)
- fix: Claude Code HTTP Remote UV path override detection
- fix: ULF detection in Claude licensing (CoplayDev#569)
- chore: Replace asmdef GUID references (CoplayDev#564)
- docs: Streamline README for faster onboarding (CoplayDev#583)
- Many new client configurators (VSCode, Cursor, Windsurf, etc.)

Fork enhancements preserved:
- "find" instruction handler in UnityTypeConverters.cs
- MarkSceneOrPrefabDirty() helper for proper Prefab Stage support
- IsInPrefabStage() and GetPrefabStageRoot() helpers
- #main URL reference (no version tags)
- TestProjects excluded

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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