59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
using IndianOceanAssets.Engine2_5D;
|
|
|
|
namespace IndianOceanAssets.EditorTools
|
|
{
|
|
[CustomEditor(typeof(BoundaryWallGenerator))]
|
|
public class BoundaryWallGeneratorEditor : UnityEditor.Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
DrawDefaultInspector();
|
|
|
|
var generator = (BoundaryWallGenerator)target;
|
|
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField("操作", EditorStyles.boldLabel);
|
|
|
|
if (GUILayout.Button("Build Walls", GUILayout.Height(32)))
|
|
{
|
|
Undo.RecordObject(generator, "Build Boundary Walls");
|
|
generator.Build();
|
|
EditorUtility.SetDirty(generator);
|
|
}
|
|
|
|
if (GUILayout.Button("Clear Walls", GUILayout.Height(24)))
|
|
{
|
|
Undo.RecordObject(generator, "Clear Boundary Walls");
|
|
generator.ClearGenerated();
|
|
EditorUtility.SetDirty(generator);
|
|
}
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
// 显示边界信息
|
|
var paths = generator.GetBoundaryPaths();
|
|
if (paths.Count > 0)
|
|
{
|
|
EditorGUILayout.LabelField("边界信息", EditorStyles.boldLabel);
|
|
int total = 0;
|
|
for (int i = 0; i < paths.Count; i++)
|
|
{
|
|
int count = paths[i].Count;
|
|
total += count;
|
|
EditorGUILayout.LabelField($" 路径 {i}: {count} 个点");
|
|
}
|
|
EditorGUILayout.LabelField($" 合计: {paths.Count} 条路径, {total} 个点");
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.HelpBox(
|
|
"未检测到边界数据。\n" +
|
|
"请指定 groundSprite(地面 SpriteRenderer)或 polygonCollider。",
|
|
MessageType.Warning);
|
|
}
|
|
}
|
|
}
|
|
}
|