当前位置:网站首页>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);
}
}
边栏推荐
- Cron表达式(七子表达式)
- 2022 Pengcheng cup Web
- FreeRTOS 中 RISC-V-Qemu-virt_GCC 的调度时机
- Paradigm in database: first paradigm, second paradigm, third paradigm
- 百问百答第45期:应用性能探针监测原理-node JS 探针
- 紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成
- SET XACT_ABORT ON
- R3live series learning (IV) r2live source code reading (2)
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- 不要再说微服务可以解决一切问题了!
猜你喜欢

COMSOL -- 3D casual painting -- sweeping

COMSOL--三维图形的建立

NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?

2022 Pengcheng cup Web

DDRx寻址原理

基于OpenHarmony的智能金属探测器

Oneforall installation and use

Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems

如何让全彩LED显示屏更加节能环保

MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
随机推荐
Mysql统计技巧:ON DUPLICATE KEY UPDATE用法
Stop saying that microservices can solve all problems!
Advanced technology management - what is the physical, mental and mental strength of managers
COMSOL--建立几何模型---二维图形的建立
sklearn模型整理
2022 chemical automation control instrument examination questions and online simulation examination
SSL证书错误怎么办?浏览器常见SSL证书报错解决办法
Dspic33ep clock initialization program
Codeforces Round #804 (Div. 2)
2048游戏逻辑
spark调优(一):从hql转向代码
CDGA|数据治理不得不坚持的六个原则
DDRx寻址原理
AutoCAD -- mask command, how to use CAD to locally enlarge drawings
Bracket matching problem (STL)
华为设备配置信道切换业务不中断
Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
Leetcode 185 All employees with the top three highest wages in the Department (July 4, 2022)
基于OpenHarmony的智能金属探测器
-26374 and -26377 errors during coneroller execution