【F11窗口】增加雷达debug面板

main
刘涛 2026-06-11 16:04:19 +08:00
parent 29d6a9c7f5
commit 3acb0fff96
3 changed files with 109 additions and 0 deletions

View File

@ -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 + ")";
}
}
}
}

View File

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

View File

@ -23,12 +23,14 @@ namespace FightDebug
private GameUnit _targetUnit; private GameUnit _targetUnit;
private int _pureDamageValue = 100; private int _pureDamageValue = 100;
private SingleUnitSearchLightDebugPanel _searchLightDebugPanel = new SingleUnitSearchLightDebugPanel(); private SingleUnitSearchLightDebugPanel _searchLightDebugPanel = new SingleUnitSearchLightDebugPanel();
private SingleUnitRadarDebugPanel _radarDebugPanel = new SingleUnitRadarDebugPanel();
public static void ShowWindow(GameUnit unit) public static void ShowWindow(GameUnit unit)
{ {
var win = GetWindow<SingleUnitWindow>("单位:" + unit.GetDescString()); var win = GetWindow<SingleUnitWindow>("单位:" + unit.GetDescString());
win._targetUnit = unit; win._targetUnit = unit;
win._GetSearchLightDebugPanel().Reset(); win._GetSearchLightDebugPanel().Reset();
win._GetRadarDebugPanel().Reset();
win.Show(); win.Show();
win.Focus(); win.Focus();
} }
@ -42,6 +44,16 @@ namespace FightDebug
return _searchLightDebugPanel; return _searchLightDebugPanel;
} }
private SingleUnitRadarDebugPanel _GetRadarDebugPanel()
{
if (_radarDebugPanel == null)
{
_radarDebugPanel = new SingleUnitRadarDebugPanel();
}
return _radarDebugPanel;
}
private double _lastRepaintTime; private double _lastRepaintTime;
@ -456,6 +468,7 @@ namespace FightDebug
private void _ShowBuildExt() private void _ShowBuildExt()
{ {
_GetSearchLightDebugPanel().Draw(_targetUnit); _GetSearchLightDebugPanel().Draw(_targetUnit);
_GetRadarDebugPanel().Draw(_targetUnit);
} }
private void _ShowVehicleExt() private void _ShowVehicleExt()