当前位置:网站首页>Unity xlua monoproxy mono proxy class
Unity xlua monoproxy mono proxy class
2022-07-05 11:26:00 【Handsome_ shuai_】
Unity Xlua Mono proxy class (MonoProxy)
- Xlua Used for mapping Unity And declare periodic functions
- Use UniRx Can achieve update Multiple bindings of , It can be bound when necessary Update To improve performance
public class MonoProxy : MonoBehaviour
{
public LuaTable luaTable;
private Action<LuaTable> luaStart;
private Action<LuaTable> luaOnDestroy;
public LuaTable BindScript(string moduleName, string scriptPath)
{
Main.Instance.LuaEnv.DoString($"require('{
scriptPath}')");
string[] arr = scriptPath.Split('/');
luaTable = Main.Instance.LuaEnv.Global.Get<LuaTable>(arr[arr.Length - 1]);
luaTable.Set("MonoProxy", this);
Action<LuaTable> luaAwake = luaTable.Get<Action<LuaTable>>("Awake");
luaAwake?.Invoke(luaTable);
luaTable.Get("Start", out luaStart);
luaTable.Get("OnDestroy", out luaOnDestroy);
return luaTable;
}
public void BindUpdate(Action action)
{
Observable.EveryUpdate().Subscribe(_ =>
{
action?.Invoke();
}).AddTo(this);
}
private void Start()
{
luaStart?.Invoke(luaTable);
}
private void OnDestroy()
{
luaOnDestroy?.Invoke(luaTable);
}
}
边栏推荐
- Modulenotfounderror: no module named 'scratch' ultimate solution
- Harbor image warehouse construction
- go语言学习笔记-分析第一个程序
- Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
- 中非 钻石副石怎么镶嵌,才能既安全又好看?
- 数据库三大范式
- Harbor镜像仓库搭建
- What does cross-border e-commerce mean? What do you mainly do? What are the business models?
- 我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
- [there may be no default font]warning: imagettfbbox() [function.imagettfbbox]: invalid font filename
猜你喜欢
COMSOL -- three-dimensional graphics random drawing -- rotation
COMSOL -- 3D casual painting -- sweeping
COMSOL -- establishment of 3D graphics
中非 钻石副石怎么镶嵌,才能既安全又好看?
Characteristics and electrical parameters of DDR4
Lombok 同时使⽤@Data和@Builder 的坑,你中招没?
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
Harbor image warehouse construction
Wechat nucleic acid detection appointment applet system graduation design completion (6) opening defense ppt
Cdga | six principles that data governance has to adhere to
随机推荐
Solve the problem of slow access to foreign public static resources
PHP中Array的hash函数实现
龙蜥社区第九次运营委员会会议顺利召开
2022 chemical automation control instrument examination questions and online simulation examination
ZCMU--1390: 队列问题(1)
I used Kaitian platform to build an urban epidemic prevention policy inquiry system [Kaitian apaas battle]
In the last process before the use of the risk control model, 80% of children's shoes are trampled here
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
Web API配置自定义路由
Repair animation 1K to 8K
Beego cross domain problem solution - successful trial
2022 mobile crane driver examination question bank and simulation examination
NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
Summary of websites of app stores / APP markets
Deepfake tutorial
Ddrx addressing principle
无密码身份验证如何保障用户隐私安全?
[advertising system] incremental training & feature access / feature elimination
[first release in the whole network] (tips for big tables) sometimes it takes only 1 minute for 2 hours of SQL operation
7.2 daily study 4