GFramework/GFramework.Godot/extensions/UnRegisterExtension.cs
GwWuYou 3e1531d7eb refactor(godot): 更新Godot模块的依赖注入配置
- 为AbstractGodotModule添加GFramework.Core.Abstractions.architecture命名空间引用
- 为UnRegisterExtension添加GFramework.Core.Abstractions.events命名空间引用
- 为GodotLogger添加GFramework.Core.Abstractions.logging命名空间引用
- 为GodotLoggerFactory添加GFramework.Core.Abstractions.logging命名空间引用
- 统一模块内部的抽象层依赖引用路径
2025-12-28 10:49:44 +08:00

23 lines
920 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.Abstractions.events;
using Godot;
namespace GFramework.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;
}
}