当前位置:网站首页>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);
}
}
边栏推荐
- How to introduce devsecops into enterprises?
- DDoS attack principle, the phenomenon of being attacked by DDoS
- Cron表达式(七子表达式)
- Golang application topic - channel
- 解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
- Three suggestions for purchasing small spacing LED display
- 中非 钻石副石怎么镶嵌,才能既安全又好看?
- DDRx寻址原理
- COMSOL--建立几何模型---二维图形的建立
- 不要再说微服务可以解决一切问题了!
猜你喜欢

Basic testing process of CSDN Software Testing Introduction

COMSOL--建立几何模型---二维图形的建立

不要再说微服务可以解决一切问题了!

comsol--三维图形随便画----回转

Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things

高校毕业求职难?“百日千万”网络招聘活动解决你的难题

Modulenotfounderror: no module named 'scratch' ultimate solution

idea设置打开文件窗口个数

AutoCAD -- mask command, how to use CAD to locally enlarge drawings

技术管理进阶——什么是管理者之体力、脑力、心力
随机推荐
go语言学习笔记-分析第一个程序
shell脚本文件遍历 str转数组 字符串拼接
Detailed explanation of MATLAB cov function
MFC pet store information management system
[LeetCode] Wildcard Matching 外卡匹配
[SWT component] content scrolledcomposite
购买小间距LED显示屏的三个建议
【爬虫】charles unknown错误
[first release in the whole network] (tips for big tables) sometimes it takes only 1 minute for 2 hours of SQL operation
C#实现WinForm DataGridView控件支持叠加数据绑定
CDGA|数据治理不得不坚持的六个原则
Basic part - basic project analysis
7.2 daily study 4
2022 mobile crane driver examination question bank and simulation examination
解决grpc连接问题Dial成功状态为TransientFailure
Leetcode 185 All employees with the top three highest wages in the Department (July 4, 2022)
The ninth Operation Committee meeting of dragon lizard community was successfully held
spark调优(一):从hql转向代码
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
如何让全彩LED显示屏更加节能环保