Skip to main content
Glama
Layers.cs1.14 kB
using System; using System.Collections.Generic; using MCPForUnity.Editor.Helpers; using Newtonsoft.Json.Linq; using UnityEngine; namespace MCPForUnity.Editor.Resources.Project { /// <summary> /// Provides dictionary of layer indices to layer names. /// </summary> [McpForUnityResource("get_layers")] public static class Layers { private const int TotalLayerCount = 32; public static object HandleCommand(JObject @params) { try { var layers = new Dictionary<int, string>(); for (int i = 0; i < TotalLayerCount; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { layers.Add(i, layerName); } } return new SuccessResponse("Retrieved current named layers.", layers); } catch (Exception e) { return new ErrorResponse($"Failed to retrieve layers: {e.Message}"); } } } }

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/CoplayDev/unity-mcp'

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