AlicizaX/Client/Assets/Books/Framework/Runtime/Debugger.md
2026-04-01 13:20:06 +08:00

69 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Debugger
## 模块概述
Debugger 模块提供运行时调试面板可查看日志、FPS、系统信息、场景信息、对象池、运行时内存等。调试窗口采用树状注册方式支持扩展自定义页面。
## 快速开始
1. 场景挂载 `DebuggerComponent`
2. 选择激活策略 `DebuggerActiveWindowType`
3. 通过 `RegisterDebuggerWindow` 扩展自定义页面
## 架构说明
```text
DebuggerComponent
└─ DebuggerService
├─ IDebuggerWindowGroup
└─ IDebuggerWindow
```
## 核心类与接口
### `IDebuggerService`
公开能力:
- `ActiveWindow`
- `DebuggerWindowRoot`
- `RegisterDebuggerWindow(...)`
- `UnregisterDebuggerWindow(...)`
- `GetDebuggerWindow(...)`
- `SelectDebuggerWindow(...)`
## API 参考
### `RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow, params object[] args)`
- 必填参数:`path`
- 必填参数:`debuggerWindow`
- 可选参数:`args`
- 返回值:无
### `UnregisterDebuggerWindow(string path)`
- 返回值:`bool`
## 完整使用示例
```csharp
using AlicizaX.Debugger.Runtime;
using UnityEngine;
public sealed class SimpleDebuggerWindow : IDebuggerWindow
{
public void Initialize(params object[] args) { }
public void Shutdown() { }
public void OnEnter() { }
public void OnLeave() { }
public void OnUpdate(float elapseSeconds, float realElapseSeconds) { }
public void OnDraw() => GUILayout.Label("Custom debug page");
}
```
## 最佳实践
- 自定义窗口只放诊断信息
- 发布环境建议仅开发版开启