Skip to content

get_components crashes Unity when serializing Cinemachine camera components #478

Closed

Description

@Cygnusfear

Description

Calling manage_gameobject with action: get_components on GameObjects containing Cinemachine components causes Unity to crash.

Steps to Reproduce

  1. Have a scene with a CinemachineCamera component
  2. Call manage_gameobject with:
    {
      "action": "get_components",
      "name": "CinemachineCamera"
    }
  3. Unity crashes

Error Log

From ~/Library/Logs/Unity/Editor.log:

Assertion failed on expression: 'ValidTRS()'
UnityEngine.Matrix4x4:GetLossyScale ()
UnityEngine.Matrix4x4:get_lossyScale ()
(wrapper dynamic-method) object:lambda_method (System.Runtime.CompilerServices.Closure,object)
Newtonsoft.Json.Serialization.ExpressionValueProvider:GetValue (object)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter:CalculatePropertyValues (...)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter:SerializeObject (...)
...

The stack trace shows recursive JSON serialization of Matrix4x4 properties that have invalid/degenerate transform values (common in Cinemachine's internal state).

Root Cause

The JSON serializer is recursively serializing Unity internal types (Matrix4x4, transforms) without filtering. When it encounters matrices with invalid TRS decomposition (which Cinemachine uses internally), it triggers the ValidTRS() assertion failure.

Suggested Fix

Add [JsonIgnore] attributes or a custom contract resolver to exclude:

  • Matrix4x4 properties
  • Internal Unity transform matrices
  • Or limit serialization depth for component properties

Environment

  • Unity 6 LTS (6000.0.x)
  • unity-mcp installed via git URL
  • macOS

🤖 Generated with Claude Code

Activity

  1. coderabbitai commented on Dec 23, 2025

    @coderabbitai
    Contributor

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Possible Duplicates

    Related Issues

    🔗 Related PRs

    #296 - fix: add parameter validation to manage_gameobject tool [merged]

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord or schedule a call!

  2. added a commit that references this issue on Dec 23, 2025
    23887a2
  3. added a commit that references this issue on Dec 24, 2025
    91b6f4d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions