-
-
Notifications
You must be signed in to change notification settings - Fork 65
Fix/material array population #323
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
Conversation
…r classes for material reflection and game object creation
…; improve logging in UnityEngine_GameObject_ReflectionConvertor
… implement dynamic call tool executor
… method to streamline code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances the Unity MCP plugin's data population and serialization capabilities by extending asset reference support in converters, improving error handling and logging in reflection converters, and adding comprehensive test coverage for material and asset population scenarios.
Key Changes
- Extended
GameObjectRefConverterto serialize/deserializeAssetPathandAssetGuidproperties, enablingGameObjectRefto carry asset metadata - Refactored
UnityEngine_GameObject_ReflectionConvertor.SetValue()to actually deserialize and set GameObject values instead of just logging warnings - Added comprehensive test infrastructure with new executor classes for creating and managing test assets (textures, prefabs, ScriptableObjects, materials, GameObjects)
Reviewed changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| Unity-MCP-Plugin/Assets/root/Runtime/Converter/JsonConverters/Types/GameObjectRefConverter.cs | Added AssetPath and AssetGuid serialization support to GameObjectRef |
| Unity-MCP-Plugin/Assets/root/Runtime/Converter/JsonConverters/Types/AssetObjectRefConverter.cs | Improved error message with converter name |
| Unity-MCP-Plugin/Assets/root/Runtime/Converter/ReflectionConverters/UnityEngine_GameObject_ReflectionConvertor.cs | Implemented actual GameObject deserialization in SetValue() and added logging to TryPopulateField() |
| Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs | New comprehensive test for validating asset field and array population |
| Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/MaterialReflectionConverterTests.cs | New test class for material reflection converter (currently with commented-out test) |
| Unity-MCP-Plugin/Assets/root/Tests/Editor/Utils/Executor/*.cs | New test utility executors for creating GameObjects, components, assets, and calling tools dynamically |
| Unity-MCP-Plugin/Assets/root/TestFiles/Scripts/DataPopulationTestScript.cs | New MonoBehaviour with various field types for testing data population |
| Unity-MCP-Plugin/Assets/root/TestFiles/Scripts/DataPopulationTestScriptableObject.cs | New ScriptableObject for testing ScriptableObject population |
| Unity-MCP-Plugin/Assets/root/Tests/Editor/RefTypes/*.cs | Removed unused ReflectorNet.Utils imports |
| Unity-MCP-Plugin/Assets/root/Tests/Editor/Tool/Assets/AssetsMaterialTests.cs | Removed unused imports |
| Unity-MCP-Plugin/Assets/root/Plugins/com.IvanMurzak.McpPlugin/netstandard2.1/McpPlugin.Common.dll | Updated binary dependency |
...-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/MaterialReflectionConverterTests.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/Utils/Executor/CreatePrefabExecutor.cs
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/Utils/Executor/CreateTextureExecutor.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs
Outdated
Show resolved
Hide resolved
...ts/root/Runtime/Converter/ReflectionConverters/UnityEngine_GameObject_ReflectionConvertor.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/Utils/Executor/AddComponentExecutor.cs
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/Utils/Executor/DynamicCallToolExecutor.cs
Outdated
Show resolved
Hide resolved
…proved clarity; update material array assertions in DataPopulationTests; remove obsolete MaterialReflectionConverterTests; optimize texture creation in CreateTextureExecutor; enhance resource management in DynamicCallToolExecutor.
…ndling; include licensing information in executor files
…improved functionality and clarity
- Created DataFieldPopulationTestScript and DataFieldPopulationTestScriptableObject classes to define various data fields for testing. - Implemented DataPropertyPopulationTestScript and DataPropertyPopulationTestScriptableObject classes to utilize properties instead of fields. - Added corresponding test scripts: DataFieldScriptableObjectPopulationTests and DataPropertyScriptableObjectPopulationTests to validate the population of fields and properties. - Updated existing tests to reference the new classes and ensure proper population of data. - Removed obsolete DataPopulationTestScriptableObject class to streamline the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 55 out of 58 changed files in this pull request and generated 5 comments.
Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/ReflectionConverter/DataPopulationTests.cs
Outdated
Show resolved
Hide resolved
...gin/Assets/root/Tests/Editor/ReflectionConverter/DataFieldScriptableObjectPopulationTests.cs
Outdated
Show resolved
Hide resolved
.../Assets/root/Tests/Editor/ReflectionConverter/DataPropertyScriptableObjectPopulationTests.cs
Outdated
Show resolved
Hide resolved
Unity-MCP-Plugin/Assets/root/Tests/Editor/SpriteConverterTest.cs
Outdated
Show resolved
Hide resolved
…eExecutor to ensure proper cleanup of created assets.
…ing for null checks
This pull request introduces significant improvements to data population and serialization logic for Unity assets, along with enhanced test coverage. The main changes include extending support for asset references in converters, improving logging and error handling in reflection converters, and adding comprehensive tests for data population and material reflection conversion.
Serialization and Converter Enhancements
AssetPathandAssetGuidproperties inGameObjectRefConverter, allowingGameObjectRefto carry asset reference data. [1] [2]AssetObjectRefConverterto include the converter's name for better debugging.Reflection Converter Improvements
UnityEngine_GameObject_ReflectionConvertor: changed logging levels, added detailed trace and error logs, and improved exception reporting when setting or populating values. [1] [2]Test Coverage Expansion
DataPopulationTestScript,DataPopulationTestScriptableObject) to cover a wide range of Unity asset types for data population scenarios. [1] [2] [3] [4]DataPopulationTestssuite to validate correct population of various asset fields and arrays in Unity components. [1] [2]Minor Cleanups
ReflectorNet.Utilsimports from several test files for better maintainability. [1] [2] [3] [4].metafiles for test assets and folders to support Unity's asset database. [1] [2] [3] [4] [5]These changes collectively improve the reliability and flexibility of asset serialization, error reporting, and automated testing for Unity MCP plugins.