TinaX.UIKit
# TinaX.UIKit
# 简介
TinaX.UIKit 为TinaX Framework提供了基于UGUI的UI管理功能 基于“页面”概念的UI管理 UI动画框架 UGUI功能扩展 package name: io.nekonya.tinax.uikit
UIKit的主要服务接口是:
TinaX.UIKit.IUIKit
namespace TinaX.UIKit
{
public interface IUIKit
{
Camera UICamera { get; }
XPipeline<IOpenUIAsyncHandler> OpenUIAsyncPipeline { get; }
XPipeline<IOpenUIHandler> OpenUIPipeline { get; }
void CloseUI(UIEntity entity, params object[] args);
void CloseUI(string UIName, params object[] args);
// ------ UIName / Args
IUIEntity OpenUI(string UIName, params object[] args);
Task<IUIEntity> OpenUIAsync(string UIName, params object[] args);
void OpenUIAsync(string UIName, Action<IUIEntity, XException> callback, params object[] args);
// ------ UIName / Behavioyr / Args
IUIEntity OpenUI(string UIName, XBehaviour behaviour, params object[] args);
Task<IUIEntity> OpenUIAsync(string UIName, XBehaviour behaviour, params object[] args);
void OpenUIAsync(string UIName, XBehaviour behaviour, Action<IUIEntity, XException> callback, params object[] args);
// ------ UIName, Params / Args
IUIEntity OpenUI(string UIName, OpenUIParam openUIParam, params object[] args);
Task<IUIEntity> OpenUIAsync(string UIName, OpenUIParam openUIParam, params object[] args);
void OpenUIAsync(string UIName, OpenUIParam openUIParam, Action<IUIEntity, XException> callback, params object[] args);
// ------ UIName / Behaviour / Params /Args
IUIEntity OpenUI(string UIName, XBehaviour behaviour, OpenUIParam openUIParam, params object[] args);
Task<IUIEntity> OpenUIAsync(string UIName, XBehaviour behaviour, OpenUIParam openUIParam, params object[] args);
void OpenUIAsync(string UIName, XBehaviour behaviour, OpenUIParam openUIParam, Action<IUIEntity, XException> callback, params object[] args);
IUIEntity OpenUIWithParam(string UIName, OpenUIParam openUIParam, params object[] args);
void OpenUIWithParamAsync(string UIName, OpenUIParam openUIParam, Action<IUIEntity, XException> callback, params object[] args);
void SetUIRouter(IRouter router);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
主要服务接口的Facade是:
TinaX.VFSKit.UIKit
1
# 设置
UI图集
设置UI图片目录后,只要勾选后面的图集选项,打包时就会将目录下的文件打包成图集
# 如何使用
创建一个“UI页”
将UI页面的Prefab配置到UIGroup中,方便后续打开UI
在UI页面的根级gameObject上添加组件“XComponent”
如果是为Lua代码制作的UI,添加LuaBehaviour组件,并设置lua文件
并将其设置为“UI处理者”
添加UGUI组件 将其拖进"XComponent"
编写一个c#层的UI控制器代码
using TinaX;
using TinaX.XComponent;
using UnityEngine.UI;
public class StartupPage : XUIBehaviour
{
[Binding("txt_Text")] //对应"XComponent"中的绑定名称
public Text txt_title;
public override async void Start()
{
txt_title.text = "Hello World";
}
}
然后,打开UI
IUIEntity mainScreen = uikit.OpenUIAsync("StartupPage", new StartupPage());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
编写一个Lua层的UI控制器代码
-- luabehaviour StartupPage
function Awake()
end
function Start()
XCore.Event.Call("Framework_Init_Completed")
txtMessage.text = game.I18N:GetText("100001")
print("=============protobuf test=============")
protoc:loadfile("cmd_login.proto")
local req = { uid = "gm200", password = "12345" }
local bytes = assert(pb.encode("ro3.LoginReq", req))
print(pb.tohex(bytes))
local resp = pb.decode("ro3.LoginReq", bytes)
dump(resp)
game.TimerManager.RegisterTimer(function()
print("2000ms later once.")
end, 2000, 1)
end
function OnOpenUIMessage(content, title)
print("========== OnOpenUIMessage==========")
end
function OnDestroy()
end
打开UI
XCore.UIKit.OpenUIAsync("StartupPage", function(ui_entity, err)
if err ~= nil then
printE("OpenUI \"StartupPage\"failed. " .. err.Message)
end
end)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
上次更新: 2023/10/17, 14:09:52 访问次数: 0