GFramework/GFramework.Core/extensions/UnRegisterExtension.cs
GwWuYou e204f899ba refactor(core): 重构框架命名空间为GFramework.Core
- 将所有framework命名空间下的类迁移至GFramework.Core命名空间
- 更新所有相关using引用从framework到Core
- 重命名项目文件夹及文件路径以匹配新的命名空间结构
- 在解决方案中添加GFramework.Core项目引用
- 配置项目依赖关系并移除旧的Generator引用冲突
- 创建独立的GFramework.Core.csproj项目文件支持多目标框架
2025-12-10 08:51:17 +08:00

26 lines
928 B
C#
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.

#if GODOT
using Godot;
using GWFramework.framework.events;
namespace GWFramework.framework.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;
}
}
#endif