Skip to main content
Glama
UnityMcpPlugin.Converters.cs5.04 kB
/* ┌──────────────────────────────────────────────────────────────────┐ │ Author: Ivan Murzak (https://github.com/IvanMurzak) │ │ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │ │ Copyright (c) 2025 Ivan Murzak │ │ Licensed under the Apache License, Version 2.0. │ │ See the LICENSE file in the project root for more information. │ └──────────────────────────────────────────────────────────────────┘ */ #nullable enable using com.IvanMurzak.McpPlugin.Common.Reflection.Convertor; using com.IvanMurzak.ReflectorNet; using com.IvanMurzak.ReflectorNet.Convertor; using com.IvanMurzak.Unity.MCP.JsonConverters; using com.IvanMurzak.Unity.MCP.Reflection.Convertor; namespace com.IvanMurzak.Unity.MCP { public partial class UnityMcpPlugin { static Reflector CreateDefaultReflector() { var reflector = new Reflector(); // Remove converters that are not needed in Unity reflector.Convertors.Remove<GenericReflectionConvertor<object>>(); reflector.Convertors.Remove<ArrayReflectionConvertor>(); // Add Unity-specific converters reflector.Convertors.Add(new UnityGenericReflectionConvertor<object>()); reflector.Convertors.Add(new UnityArrayReflectionConvertor()); // Unity types reflector.Convertors.Add(new UnityEngine_Color32_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Color_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Matrix4x4_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Quaternion_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Vector2_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Vector2Int_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Vector3_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Vector3Int_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Vector4_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Bounds_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_BoundsInt_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Rect_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_RectInt_ReflectionConvertor()); // Components reflector.Convertors.Add(new UnityEngine_Object_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_GameObject_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Component_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Transform_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Renderer_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_MeshFilter_ReflectionConvertor()); // Assets reflector.Convertors.Add(new UnityEngine_Material_ReflectionConvertor()); reflector.Convertors.Add(new UnityEngine_Sprite_ReflectionConvertor()); // Json Converters // --------------------------------------------------------- // Unity types reflector.JsonSerializer.AddConverter(new Color32Converter()); reflector.JsonSerializer.AddConverter(new ColorConverter()); reflector.JsonSerializer.AddConverter(new Matrix4x4Converter()); reflector.JsonSerializer.AddConverter(new QuaternionConverter()); reflector.JsonSerializer.AddConverter(new Vector2Converter()); reflector.JsonSerializer.AddConverter(new Vector2IntConverter()); reflector.JsonSerializer.AddConverter(new Vector3Converter()); reflector.JsonSerializer.AddConverter(new Vector3IntConverter()); reflector.JsonSerializer.AddConverter(new Vector4Converter()); reflector.JsonSerializer.AddConverter(new BoundsConverter()); reflector.JsonSerializer.AddConverter(new BoundsIntConverter()); reflector.JsonSerializer.AddConverter(new RectConverter()); reflector.JsonSerializer.AddConverter(new RectIntConverter()); // Reference types reflector.JsonSerializer.AddConverter(new ObjectRefConverter()); reflector.JsonSerializer.AddConverter(new AssetObjectRefConverter()); reflector.JsonSerializer.AddConverter(new GameObjectRefConverter()); reflector.JsonSerializer.AddConverter(new ComponentRefConverter()); return reflector; } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IvanMurzak/Unity-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server