当前位置:网站首页>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);
}
}
边栏推荐
- go语言学习笔记-分析第一个程序
- 跨境电商是啥意思?主要是做什么的?业务模式有哪些?
- Cron表达式(七子表达式)
- Modulenotfounderror: no module named 'scratch' ultimate solution
- spark调优(一):从hql转向代码
- 7.2 daily study 4
- 购买小间距LED显示屏的三个建议
- 龙蜥社区第九次运营委员会会议顺利召开
- Question and answer 45: application of performance probe monitoring principle node JS probe
- Spark Tuning (I): from HQL to code
猜你喜欢

Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022

2022 chemical automation control instrument examination questions and online simulation examination

Evolution of multi-objective sorting model for classified tab commodity flow
![[office] eight usages of if function in Excel](/img/ce/ea481ab947b25937a28ab5540ce323.png)
[office] eight usages of if function in Excel

数据库三大范式

Oneforall installation and use
![[Oracle] use DataGrid to connect to Oracle Database](/img/4f/886378667889f730eaed39b97f0a39.png)
[Oracle] use DataGrid to connect to Oracle Database

COMSOL -- 3D casual painting -- sweeping

Summary of thread and thread synchronization under window

COMSOL--三维随便画--扫掠
随机推荐
Three suggestions for purchasing small spacing LED display
Intelligent metal detector based on openharmony
Modulenotfounderror: no module named 'scratch' ultimate solution
How can edge computing be combined with the Internet of things?
[TCP] TCP connection status JSON output on the server
Lombok 同时使⽤@Data和@Builder 的坑,你中招没?
SLAM 01. Modeling of human recognition Environment & path
DDR4硬件原理图设计详解
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
C#实现WinForm DataGridView控件支持叠加数据绑定
华为设备配置信道切换业务不中断
Cron expression (seven subexpressions)
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
How does redis implement multiple zones?
使用GBase 8c数据库过程中报错:80000305,Host ips belong to different cluster ,怎么解决?
OneForAll安装使用
无密码身份验证如何保障用户隐私安全?
7 themes and 9 technology masters! Dragon Dragon lecture hall hard core live broadcast preview in July, see you tomorrow
Go language learning notes - analyze the first program
中非 钻石副石怎么镶嵌,才能既安全又好看?