Feat: Add CRUD operations for Shader files via MCP #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new tool within the MCP bridge for managing Unity shader files directly from an external process.
Motivation
To enable external build tools, content pipelines, or automated scripts to create, read, update, and delete Unity shader assets programmatically without direct user interaction with the Unity Editor UI. This enhances automation capabilities for shader development workflows.
Key Changes
ManageShader
class: Added a dedicated class (UnityMcpBridge.Editor.Tools.ManageShader
) to handle shader-specific operations.HandleCommand
method to support the following actions:create
: Creates a new.shader
file. Accepts optional initial content (plain text or Base64 encoded). Generates default shader content if none is provided.read
: Reads the content of an existing.shader
file. Returns plain text content and also Base64 encoded content if the file is large.update
: Overwrites the content of an existing.shader
file. Requires content to be provided.delete
: Deletes a.shader
file usingAssetDatabase.DeleteAsset
.Assets/
directory. Defaults to placing new shaders in a "Shaders" subdirectory if no path is specified. Handles forward and backslashes.EncodeBase64
,DecodeBase64
) to handle potentially large shader contents efficiently via Base64 encoding in the request/response payload.AssetDatabase.ImportAsset
andAssetDatabase.DeleteAsset
to ensure Unity's asset database is correctly updated after file operations.This addition significantly expands the MCP bridge's functionality, providing robust external control over shader assets.
Please review the changes.