mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 调整了 Architecture 类中字段和方法的布局,提升可读性 - 优化了命令执行逻辑,明确区分有无返回值的命令处理 - 规范了接口和抽象类的注释格式,增强文档清晰度 - 统一了代码风格,对齐缩进与换行符使用 - 补充了事件系统中泛型事件类的功能实现 - 完善了 README 文档中的条目结构和内容表述
23 lines
912 B
C#
23 lines
912 B
C#
using GFramework.Core.events;
|
||
using Godot;
|
||
|
||
namespace GFramework.Core.Godot.extensions;
|
||
|
||
/// <summary>
|
||
/// 提供取消注册扩展方法的静态类
|
||
/// </summary>
|
||
public static class UnRegisterExtension
|
||
{
|
||
/// <summary>
|
||
/// 当节点退出场景树时自动取消注册监听器
|
||
/// </summary>
|
||
/// <param name="unRegister">需要在节点退出时被取消注册的监听器接口实例</param>
|
||
/// <param name="node">Godot节点对象,当该节点退出场景树时触发取消注册操作</param>
|
||
/// <returns>返回传入的原始IUnRegister实例,支持链式调用</returns>
|
||
public static IUnRegister UnRegisterWhenNodeExitTree(this IUnRegister unRegister, Node node)
|
||
{
|
||
// 监听节点的TreeExiting事件,在节点即将退出场景树时执行取消注册操作
|
||
node.TreeExiting += unRegister.UnRegister;
|
||
return unRegister;
|
||
}
|
||
} |