chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 959ee428299454ac19a636275208ca00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MCPForUnity.Editor.Helpers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
|
||||
|
||||
namespace MCPForUnity.Editor.Resources.Project
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides static project configuration information.
|
||||
/// </summary>
|
||||
[McpForUnityResource("get_project_info")]
|
||||
public static class ProjectInfo
|
||||
{
|
||||
public static object HandleCommand(JObject @params)
|
||||
{
|
||||
try
|
||||
{
|
||||
string assetsPath = Application.dataPath.Replace('\\', '/');
|
||||
string projectRoot = Directory.GetParent(assetsPath)?.FullName.Replace('\\', '/');
|
||||
string projectName = Path.GetFileName(projectRoot);
|
||||
|
||||
var info = new
|
||||
{
|
||||
projectRoot = projectRoot ?? "",
|
||||
projectName = projectName ?? "",
|
||||
unityVersion = Application.unityVersion,
|
||||
platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
|
||||
assetsPath = assetsPath,
|
||||
renderPipeline = RenderPipelineUtility.GetActivePipeline().ToString(),
|
||||
activeInputHandler = GetActiveInputHandler(),
|
||||
packages = new
|
||||
{
|
||||
ugui = IsPackageInstalled("com.unity.ugui"),
|
||||
textmeshpro = IsPackageInstalled("com.unity.textmeshpro"),
|
||||
inputsystem = IsPackageInstalled("com.unity.inputsystem"),
|
||||
uiToolkit = true,
|
||||
screenCapture = true,
|
||||
}
|
||||
};
|
||||
|
||||
return new SuccessResponse("Retrieved project info.", info);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse($"Error getting project info: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads PlayerSettings.activeInputHandler via reflection to avoid
|
||||
/// compile-time dependency on the Input System package.
|
||||
/// Returns "Old" (0), "New" (1), or "Both" (2).
|
||||
/// </summary>
|
||||
private static string GetActiveInputHandler()
|
||||
{
|
||||
try
|
||||
{
|
||||
var prop = typeof(PlayerSettings).GetProperty(
|
||||
"activeInputHandler",
|
||||
BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
|
||||
if (prop == null)
|
||||
return "Old";
|
||||
|
||||
int value = (int)prop.GetValue(null);
|
||||
return value switch
|
||||
{
|
||||
0 => "Old",
|
||||
1 => "New",
|
||||
2 => "Both",
|
||||
_ => "Old"
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Old";
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsPackageInstalled(string packageName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return PackageInfo.FindForAssetPath("Packages/" + packageName) != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81b03415fcf93466e9ed667d19b58d43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using MCPForUnity.Editor.Helpers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace MCPForUnity.Editor.Resources.Project
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides list of all tags in the project.
|
||||
/// </summary>
|
||||
[McpForUnityResource("get_tags")]
|
||||
public static class Tags
|
||||
{
|
||||
public static object HandleCommand(JObject @params)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] tags = InternalEditorUtility.tags;
|
||||
return new SuccessResponse("Retrieved current tags.", tags);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse($"Failed to retrieve tags: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2179ac5d98f264d1681e7d5c0d0ed341
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user