diff --git a/Godot/script_templates/Node/PageControllerTemplate.cs b/Godot/script_templates/Node/PageControllerTemplate.cs new file mode 100644 index 0000000..808c1d1 --- /dev/null +++ b/Godot/script_templates/Node/PageControllerTemplate.cs @@ -0,0 +1,87 @@ +// meta-name: UI页面控制器类模板 +// meta-description: 负责管理UI页面场景的生命周期和架构关联 +using Godot; +using GFramework.Core.Abstractions.controller; +using GFramework.Core.extensions; +using GFramework.Game.Abstractions.ui; +using GFramework.Godot.ui; +using GFramework.SourceGenerators.Abstractions.logging; +using GFramework.SourceGenerators.Abstractions.rule; + + +[ContextAware] +[Log] +public partial class _CLASS_ :_BASE_,IController,IUiPageBehaviorProvider,IUiPage +{ + /// + /// 节点准备就绪时的回调方法 + /// 在节点添加到场景树后调用 + /// + public override void _Ready() + { + + } + /// + /// 页面行为实例的私有字段 + /// + private IUiPageBehavior? _page; + + /// + /// 获取页面行为实例,如果不存在则创建新的CanvasItemUiPageBehavior实例 + /// + /// 返回IUiPageBehavior类型的页面行为实例 + public IUiPageBehavior GetPage() + { + _page ??= new CanvasItemUiPageBehavior<_BASE_>(this); + return _page; + } + + /// + /// 页面进入时调用的方法 + /// + /// 页面进入参数,可能为空 + public void OnEnter(IUiPageEnterParam? param) + { + _log.Info("测试主菜单 OnEnter"); + } + /// + /// 页面退出时调用的方法 + /// + public void IUiPage.OnExit() + { + + } + + + /// + /// 页面暂停时调用的方法 + /// + public void IUiPage.OnPause() + { + + } + + /// + /// 页面恢复时调用的方法 + /// + public void IUiPage.OnResume() + { + + } + + /// + /// 页面显示时调用的方法 + /// + public void IUiPage.OnShow() + { + + } + + /// + /// 页面隐藏时调用的方法 + /// + public void IUiPage.OnHide() + { + + } +} \ No newline at end of file