Curtain 0.0.2

dotnet add package Curtain --version 0.0.2
                    
NuGet\Install-Package Curtain -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Curtain" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Curtain" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Curtain" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Curtain --version 0.0.2
                    
#r "nuget: Curtain, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Curtain@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Curtain&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Curtain&version=0.0.2
                    
Install as a Cake Tool

Curtain

一个游戏 UI 管理框架,提供页面与对话框的统一打开、关闭和层级管理能力。核心引擎无关,后续将提供 Unity、Godot 等引擎桥接。

安装

dotnet add package Curtain

特点

  • 页面管理:支持主界面、普通页面、顶层页面,以及多开计数。
  • 对话框:支持带返回值,可异步等待用户操作结果;父界面关闭时自动级联关闭子对话框。
  • 参数注入:打开页面或对话框时可传入参数,类型安全。
  • 层级控制:内置 Main、Stack、Effect、Top 四个层级,可一键关闭普通页面(保留主界面与顶层)。
  • 生命周期清晰:View 通过 OnInitialize / OnHideAsync 处理初始化与关闭收尾,框架负责调用时机。
  • 资源自动释放:View 通过 AddDisposable 注册的订阅,在销毁时自动释放。
  • 核心引擎无关:核心逻辑不依赖任何引擎类型,便于独立测试;后续可扩展 Unity、Godot 等引擎桥接。

快速开始

// 定义页面
[UI("UI/Page/ShopPage")]
public class ShopPageView : ViewBase
{
    protected override void OnInitialize()
    {
        // 初始化:缓存控件、创建数据、播放入场动画
    }
}
// 打开页面
await uiManager.OpenMainAsync<ShopPageView>();
await uiManager.OpenPageAsync<ShopPageView>(UILayer.Stack);

// 带参数打开
await uiManager.OpenPageAsync<ShopPageView, ShopParam>(param);

// 关闭页面
UIHandle handle = await uiManager.OpenMainAsync<ShopPageView>();
handle.Dispose();

// 关闭所有普通页面(主界面和顶层保留)
uiManager.CloseAll();

对话框

// 对话框 View:接收结果句柄,用户操作后返回结果
[UI("UI/Dialog/ConfirmDialog")]
public class ConfirmDialogView : ViewBase, IViewWithResult
{
    private UIHandle _resultHandle;

    public void SetResultHandle(UIHandle handle)
    {
        _resultHandle = handle;
    }

    public void OnConfirm()
    {
        ((UIHandle<bool>)_resultHandle).Complete(true);
    }
}
// 打开并等待结果
UIHandle<bool> dialog = await uiManager.OpenDialogAsync<ConfirmDialogView, bool>(parentHandle);
UIResult<bool> result = await dialog.GetResult();
if (result.IsCompleted)
{
    // 用户确认,result.Value 为返回值
}

层级说明

层级 用途 CloseAll 行为
Main 主界面,打开新的会替换旧的 保留
Stack 普通页面和对话框 关闭
Effect 特效(飞金币、飘字等) 保留
Top 新手引导、公告、强制更新 保留

View 生命周期

  • OnInitialize():打开时调用一次,做初始化。
  • OnHideAsync():关闭前调用,播放出场动画或清理,框架会等待完成。
  • AddDisposable(...):注册订阅,View 销毁时自动释放。
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 108 9/7/2026
0.0.1 106 9/7/2026