From 3acb0fff969c5a45c0489969c836422fbb6865ac Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Thu, 11 Jun 2026 16:04:19 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90F11=E7=AA=97=E5=8F=A3=E3=80=91?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9B=B7=E8=BE=BEdebug=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FightDebug/SingleUnitRadarDebugPanel.cs | 85 +++++++++++++++++++ .../SingleUnitRadarDebugPanel.cs.meta | 11 +++ .../Editor/FightDebug/SingleUnitWindow.cs | 13 +++ 3 files changed, 109 insertions(+) create mode 100644 ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs create mode 100644 ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs.meta diff --git a/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs new file mode 100644 index 00000000000..e0a3efebb6c --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs @@ -0,0 +1,85 @@ +using GamePlay.Building.Fight.Impl.Builds; +using Gameplay.Common; +using Gameplay.Character; +using Gameplay.Unit; +using UnityEditor; +using UnityEngine; + +namespace FightDebug +{ + public class SingleUnitRadarDebugPanel + { + public void Reset() + { + } + + public void Draw(GameUnit unit) + { + var radar = unit as UnitBuildRadar; + if (radar == null) + { + return; + } + + _DrawRadar(radar); + } + + private void _DrawRadar(UnitBuildRadar radar) + { + GUILayout.BeginVertical("box"); + GUILayout.Label("雷达调试", EditorStyles.boldLabel); + + _ShowLabel("建筑阵营:", _GetTroopName(radar.commonData.troopId)); + _ShowLabel("建筑ID:", radar.GetID() + "", true); + _ShowLabel("LocalId:", radar.unitLevelData != null ? radar.unitLevelData.LocalId + "" : "无", true); + _ShowLabel("当前格子:", radar.transData.cellIndex + "", true); + _ShowLabel("世界坐标:", _FormatVector3(radar.transData.pos)); + _ShowLabel("当前逻辑角度:", radar.nowAngle.ToString("F2") + "°"); + _ShowLabel("当前表现角度:", radar.DebugViewAngle.ToString("F2") + "°"); + _ShowLabel("当前范围:", radar.scanDistance.ToString("F2")); + _ShowLabel("扫描格数:", radar.scanCellCount + "格"); + _ShowLabel("单格直径:", (CodeDefine.Fight.Cell.CELL_MIN_RADIUS * 2F).ToString("F2")); + _ShowLabel("中心半径修正:", "-" + CodeDefine.Fight.Cell.CELL_MIN_RADIUS.ToString("F2")); + _ShowLabel("扫描扇形角:", radar.scanAngle.ToString("F2") + "°"); + _ShowLabel("扫描速度:", radar.scanSpeed.ToString("F2") + "°/s"); + + GUILayout.EndVertical(); + } + + private void _ShowLabel(string label, string value, bool showCopy = false) + { + GUILayout.BeginHorizontal(); + GUILayout.Label(label, GUILayout.Width(140)); + GUILayout.Label(value); + if (showCopy) + { + if (GUILayout.Button("复制", GUILayout.Width(60))) + { + EditorGUIUtility.systemCopyBuffer = value; + } + } + + GUILayout.EndHorizontal(); + } + + private string _FormatVector3(Vector3 pos) + { + return $"({pos.x:F2}, {pos.y:F2}, {pos.z:F2})"; + } + + private string _GetTroopName(int troopId) + { + switch (troopId) + { + case ETroopsId.Self: + return "己方"; + case ETroopsId.Enemy: + return "敌方"; + case ETroopsId.Neutral: + return "中立"; + default: + return "未知(" + troopId + ")"; + } + } + } +} diff --git a/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs.meta b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs.meta new file mode 100644 index 00000000000..421313f6589 --- /dev/null +++ b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitRadarDebugPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1aea4098196d66b4fbb17cb150a958e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectNLD/Assets/Editor/FightDebug/SingleUnitWindow.cs b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitWindow.cs index 859a230ff9e..254d3a6ddb5 100644 --- a/ProjectNLD/Assets/Editor/FightDebug/SingleUnitWindow.cs +++ b/ProjectNLD/Assets/Editor/FightDebug/SingleUnitWindow.cs @@ -23,12 +23,14 @@ namespace FightDebug private GameUnit _targetUnit; private int _pureDamageValue = 100; private SingleUnitSearchLightDebugPanel _searchLightDebugPanel = new SingleUnitSearchLightDebugPanel(); + private SingleUnitRadarDebugPanel _radarDebugPanel = new SingleUnitRadarDebugPanel(); public static void ShowWindow(GameUnit unit) { var win = GetWindow("单位:" + unit.GetDescString()); win._targetUnit = unit; win._GetSearchLightDebugPanel().Reset(); + win._GetRadarDebugPanel().Reset(); win.Show(); win.Focus(); } @@ -42,6 +44,16 @@ namespace FightDebug return _searchLightDebugPanel; } + + private SingleUnitRadarDebugPanel _GetRadarDebugPanel() + { + if (_radarDebugPanel == null) + { + _radarDebugPanel = new SingleUnitRadarDebugPanel(); + } + + return _radarDebugPanel; + } private double _lastRepaintTime; @@ -456,6 +468,7 @@ namespace FightDebug private void _ShowBuildExt() { _GetSearchLightDebugPanel().Draw(_targetUnit); + _GetRadarDebugPanel().Draw(_targetUnit); } private void _ShowVehicleExt()