feat(Materials): 更新CoreBattleGround材质贴图和缩放参数
更换了CoreBattleGround材质的主纹理,将纹理GUID从73e4d6cf089824c0cadfcefa5b15d306
更新为c6af6f473739fb546ac7775e5c957da1,并调整纹理缩放参数从{x: 3, y: 4}修改为
{x: 1, y: 1},同时移除了多余的_MetallicGlossMap配置项。
```
112 lines
3.9 KiB
C#
112 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Codely.Newtonsoft.Json.Linq;
|
|
using UnityEngine;
|
|
using UnityTcp.Editor.Helpers;
|
|
|
|
namespace UnityTcp.Editor.Tools
|
|
{
|
|
/// <summary>
|
|
/// INTERNAL TOOL - NOT EXPOSED TO LLM.
|
|
/// Receives notifications from external agentic tools when they modify files
|
|
/// that may affect Unity's state.
|
|
///
|
|
/// This tool should only be called by the agent execution layer,
|
|
/// not directly by LLM tool invocations.
|
|
/// </summary>
|
|
public static class _InternalStateDirtyNotifier
|
|
{
|
|
/// <summary>
|
|
/// Handle dirty state notification from external tools.
|
|
/// </summary>
|
|
private static readonly Dictionary<string, Func<JObject, object>> ActionHandlers =
|
|
new Dictionary<string, Func<JObject, object>>
|
|
{
|
|
{ "notify_file_changed", NotifyFileChanged },
|
|
{ "notify_batch_changes", NotifyBatchChanges },
|
|
{ "get_statistics", _ => GetStatistics() },
|
|
};
|
|
|
|
public static object HandleCommand(JObject @params)
|
|
=> ActionRouter.Route(@params, ActionHandlers);
|
|
|
|
/// <summary>
|
|
/// Notify Unity that a single file was changed by an external tool.
|
|
/// </summary>
|
|
private static object NotifyFileChanged(JObject @params)
|
|
{
|
|
try
|
|
{
|
|
string filePath = @params["file_path"]?.ToString();
|
|
string toolName = @params["tool_name"]?.ToString() ?? "unknown";
|
|
|
|
if (string.IsNullOrEmpty(filePath))
|
|
return Response.Error("[INTERNAL] 'file_path' parameter required");
|
|
|
|
UnityStateDirtyHook.NotifyFileChanged(filePath, toolName);
|
|
|
|
return Response.Success(
|
|
$"[INTERNAL] File change notification recorded: {filePath}",
|
|
new { filePath = filePath, toolName = toolName }
|
|
);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return Response.Error($"[INTERNAL] Failed to notify file change: {e.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify Unity of multiple file changes in a batch (more efficient).
|
|
/// </summary>
|
|
private static object NotifyBatchChanges(JObject @params)
|
|
{
|
|
try
|
|
{
|
|
var filesArray = @params["files"] as JArray;
|
|
string toolName = @params["tool_name"]?.ToString() ?? "unknown";
|
|
|
|
if (filesArray == null || filesArray.Count == 0)
|
|
return Response.Error("[INTERNAL] 'files' array parameter required");
|
|
|
|
int notified = 0;
|
|
foreach (var fileToken in filesArray)
|
|
{
|
|
string filePath = fileToken.ToString();
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
{
|
|
UnityStateDirtyHook.NotifyFileChanged(filePath, toolName);
|
|
notified++;
|
|
}
|
|
}
|
|
|
|
return Response.Success(
|
|
$"[INTERNAL] Batch notification recorded: {notified} files",
|
|
new { count = notified, toolName = toolName }
|
|
);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return Response.Error($"[INTERNAL] Failed to notify batch changes: {e.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get statistics about dirty notifications (for debugging).
|
|
/// </summary>
|
|
private static object GetStatistics()
|
|
{
|
|
try
|
|
{
|
|
var stats = UnityStateDirtyHook.GetStatistics();
|
|
return Response.Success("[INTERNAL] Dirty hook statistics", stats);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return Response.Error($"[INTERNAL] Failed to get statistics: {e.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|