GwWuYou fdc51e23b7 refactor(godot): 重构Godot相关扩展并迁移至新项目结构
- 将NodeExtensions和UnRegisterExtension迁移至GFramework.Core.Godot项目
- 更新命名空间以匹配新的项目结构
- 为扩展方法参数添加可空注解以提高安全性
- 移除旧的条件编译指令#if GODOT和#endif
- 创建新的GFramework.Core.Godot.csproj项目文件
- 在解决方案中注册新的GFramework.Core.Godot项目
- 更新主项目文件以排除新项目中的文件冲突
- 添加GodotSharpEditor包引用以支持Godot编辑器功能
- 链接新项目的扩展文件到原有路径以保持兼容性
2025-12-11 10:14:00 +08:00

23 lines
910 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.

using GFramework.Core.events;
using Godot;
namespace GFramework.Core.Godot.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;
}
}