-
-
Notifications
You must be signed in to change notification settings - Fork 302
Feature: 🔍 Enhanced Component Data Reading via Serialization #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature: 🔍 Enhanced Component Data Reading via Serialization #93
Conversation
…ializer helper Moved serialization logic (GetGameObjectData, GetComponentData, metadata caching, JSON conversion helpers) from ManageGameObject tool to a dedicated GameObjectSerializer class in the Helpers namespace. This improves separation of concerns and reduces the size/complexity of ManageGameObject.cs. Updated ManageGameObject to use the new helper class.
You can see the full CodeRabbit of this PR on my fork: dsarno#2 |
The Unity Editor was crashing with ValidTRS() assertions when attempting to get components from certain GameObjects like the Main Camera. Investigation revealed the crash occurred during JSON serialization when reflection code accessed specific matrix properties (e.g., Camera.cullingMatrix, Transform.rotation, Transform.lossyScale). Accessing these properties appears to trigger internal Transform state validation failures, potentially due to interactions with the JSON serializer's reflection mechanism. This fix addresses the issue by: - Replacing LINQ iteration in GetComponentsFromTarget with a standard loop over a copied list to prevent potential premature serialization interactions. - Explicitly skipping known problematic Camera matrix properties (cullingMatrix, pixelRect, rect) and generic matrix properties (worldToLocalMatrix, localToWorldMatrix) within GetComponentData's reflection logic. - Retaining manual serialization for Transform component properties to avoid related reflection issues.
One of my Cursor cleanups deleted a bunch of @justinpbarnett 's comments in ManageGameObject.cs. I tried to restore them from a diff but there were too many and it didn't really work. We could either ask for AI help to regenerate inline comments, or I can try to rebuild the whole file based on your commented version (actually already did try that, and it wasn't that easy). Let me know what you think and thanks! |
…sform and Camera components to prevent serialization crashes
- Add get_components to the list of available actions in the docstring - Document required and optional parameters for get_components action - Clarify the return value structure for get_components - Improve overall documentation clarity for component data retrieval
@justinpbarnett Think you'll have a few minutes to try it? Spent a solid couple days putting it together. |
This PR enhances the
ManageGameObject
tool to supercharge its ability to read component data accurately and comprehensively! 🚀 Basically, it can read serialized data from a bunch of different kinds of standard and custom components, and can be extended to work with even more components.Summary:
JsonConverter
implementations (Vector3Converter
,ColorConverter
,UnityEngineObjectConverter
, etc.). This means theget_components
action can reliably pull detailed info for all sorts of component data types.ManageGameObject.cs
into a new, dedicatedGameObjectSerializer
helper class (UnityMcpBridge.Editor.Helpers.GameObjectSerializer
).Enhanced Capabilities (
get_components
action):The
get_components
action now reliably retrieves detailed information for components attached to GameObjects, including:[SerializeField]
(usingincludeNonPublicSerialized: true
) 👀Examples:
Get all component data for 'MCP_TestData':
Inspect a UI element ('InventoryPanel'):
Future Considerations:
GameObjectSerializer
and theUnityMcpBridge.Runtime.Serialization
converters provide a solid foundation. We can easily add support for more complex or custom data types in the future by creating newJsonConverter
implementations, making this tool even more powerful! 💪(Note: This PR also implicitly includes commits that added missing essential package files (
.asmdef
,.meta
, runtime scripts) to the repository, which were necessary to resolve compilation errors when loading the package remotely via Git.)Summary by CodeRabbit
New Features
Enhancements