添加mcp服务器

优化敌人AI,修改成双重规则寻敌
This commit is contained in:
2026-06-28 23:08:20 +08:00
parent 3da879f58d
commit 6cc4f1035d
9 changed files with 473 additions and 116 deletions

View File

@@ -0,0 +1,102 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.Tilemaps;
/// <summary>
/// Tilemap Y-Sort工具 - 快速给Tilemap添加YSorter
/// </summary>
public class TilemapYSortTool : Editor
{
[MenuItem("Tools/Tilemap/给选中Tilemap添加YSorter")]
public static void AddYSorterToTilemap()
{
if (Selection.gameObjects.Length == 0)
{
EditorUtility.DisplayDialog("提示", "请先选择Tilemap物体", "确定");
return;
}
int count = 0;
foreach (GameObject go in Selection.gameObjects)
{
// 检查是否有TilemapRenderer
TilemapRenderer renderer = go.GetComponentInChildren<TilemapRenderer>();
if (renderer == null)
{
Debug.LogWarning($"跳过 {go.name} - 没有TilemapRenderer组件");
continue;
}
// 检查是否已有YSorter
if (go.GetComponent<YSorter>() != null)
{
Debug.Log($"跳过 {go.name} - 已有YSorter");
continue;
}
// 添加YSorter
YSorter ySorter = go.AddComponent<YSorter>();
// 设置默认的baseSortingOrder
SerializedObject so = new SerializedObject(ySorter);
SerializedProperty prop = so.FindProperty("baseSortingOrder");
if (prop != null)
{
prop.intValue = renderer.sortingOrder;
so.ApplyModifiedProperties();
}
EditorUtility.SetDirty(go);
count++;
Debug.Log($"✓ 已添加YSorter到 {go.name} (baseSortingOrder: {renderer.sortingOrder})");
}
if (count > 0)
{
EditorUtility.DisplayDialog("完成", $"已给 {count} 个Tilemap添加YSorter", "确定");
}
}
[MenuItem("Tools/Tilemap/批量添加YSorter到所有Tilemap")]
public static void AddYSorterToAllTilemaps()
{
TilemapRenderer[] allRenderers = FindObjectsByType<TilemapRenderer>(FindObjectsSortMode.None);
if (allRenderers.Length == 0)
{
EditorUtility.DisplayDialog("提示", "场景中没有找到TilemapRenderer", "确定");
return;
}
int count = 0;
foreach (TilemapRenderer renderer in allRenderers)
{
GameObject go = renderer.gameObject;
if (go.GetComponent<YSorter>() != null)
{
Debug.Log($"跳过 {go.name} - 已有YSorter");
continue;
}
YSorter ySorter = go.AddComponent<YSorter>();
SerializedObject so = new SerializedObject(ySorter);
SerializedProperty prop = so.FindProperty("baseSortingOrder");
if (prop != null)
{
prop.intValue = renderer.sortingOrder;
so.ApplyModifiedProperties();
}
EditorUtility.SetDirty(go);
count++;
Debug.Log($"✓ 已添加YSorter到 {go.name} (baseSortingOrder: {renderer.sortingOrder})");
}
if (count > 0)
{
EditorUtility.DisplayDialog("完成", $"已给 {count} 个Tilemap添加YSorter", "确定");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: CH5JsXykVyiioh6PdpvMd04QErrpba3U3rPu7hQrZpCz8EMMsg29s0w=
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: