unity-mcp/MCPForUnity/Editor/Windows
dsarno 91b6f4d8d6
Test/478 matrix4x4 serialization crash (#481)
* Fix #478: Add Matrix4x4Converter to prevent Cinemachine serialization crash

The `get_components` action crashes Unity when serializing Cinemachine
camera components because Newtonsoft.Json accesses computed Matrix4x4
properties (lossyScale, rotation) that call ValidTRS() on non-TRS matrices.

This fix adds a safe Matrix4x4Converter that only accesses raw matrix
elements (m00-m33), avoiding the dangerous computed properties entirely.

Changes:
- Add Matrix4x4Converter to UnityTypeConverters.cs
- Register converter in GameObjectSerializer serializer settings

Tested with Cinemachine 3.1.5 on Unity 6 - get_components now returns
full component data without crashing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add unit tests for Matrix4x4Converter

Tests cover:
- Identity matrix serialization/deserialization
- Translation matrix round-trip
- Degenerate matrix (determinant=0) - key regression test
- Non-TRS matrix (projection) - validates ValidTRS() is never called
- Null handling
- Ensures dangerous properties are not in output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Address code review feedback

- Fix null handling consistency: return zero matrix instead of identity
  (consistent with missing field defaults of 0f)
- Improve degenerate matrix test to verify:
  - JSON only contains raw mXY properties
  - Values roundtrip correctly
- Rename test to reflect expanded coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Move tests to TestProject per review feedback

Moved Matrix4x4ConverterTests from MCPForUnity/Editor/Tests/ to
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/ as requested.

Also added MCPForUnity.Runtime reference to the test asmdef since
the converter lives in the Runtime assembly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix Matrix4x4 deserialization guard + UI Toolkit USS warning

---------

Co-authored-by: Alexander Mangel <cygnusfear@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 15:53:14 -08:00
..
Components Add .meta files (#472) 2025-12-19 18:59:19 -04:00
Components.meta HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
MCPForUnityEditorWindow.cs [FEATURE] Camera Capture (#449) 2025-12-09 19:00:30 -05:00
MCPForUnityEditorWindow.cs.meta Add .meta files (#472) 2025-12-19 18:59:19 -04:00
MCPForUnityEditorWindow.uss Test/478 matrix4x4 serialization crash (#481) 2025-12-23 15:53:14 -08:00
MCPForUnityEditorWindow.uss.meta Add .meta files (#472) 2025-12-19 18:59:19 -04:00
MCPForUnityEditorWindow.uxml [FEATURE] Custom Tool Fix and Add inspection window for all the tools (#414) 2025-12-07 19:38:32 -05:00
MCPForUnityEditorWindow.uxml.meta Add .meta files (#472) 2025-12-19 18:59:19 -04:00
MCPSetupWindow.cs Fix manage prefabs (#405) 2025-11-28 18:47:11 -04:00
MCPSetupWindow.cs.meta HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
MCPSetupWindow.uss HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
MCPSetupWindow.uss.meta HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
MCPSetupWindow.uxml HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
MCPSetupWindow.uxml.meta HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00