当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
Basics - rest style development
How to introduce devsecops into enterprises?
CDGA|数据治理不得不坚持的六个原则
紫光展锐全球首个5G R17 IoT NTN卫星物联网上星实测完成
AutoCAD -- mask command, how to use CAD to locally enlarge drawings
如何将 DevSecOps 引入企业?
购买小间距LED显示屏的三个建议
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
Detailed explanation of DDR4 hardware schematic design
Harbor image warehouse construction
随机推荐
Web API配置自定义路由
NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
【爬虫】charles unknown错误
项目总结笔记系列 wsTax KT Session2 代码分析
AUTOCAD——遮罩命令、如何使用CAD对图纸进行局部放大
管理多个Instagram帐户防关联小技巧大分享
Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
Intelligent metal detector based on openharmony
Harbor镜像仓库搭建
[SWT component] content scrolledcomposite
7.2每日学习4
In the last process before the use of the risk control model, 80% of children's shoes are trampled here
comsol--三维图形随便画----回转
OneForAll安装使用
基于OpenHarmony的智能金属探测器
解决访问国外公共静态资源速度慢的问题
The art of communication III: Listening between people
Cron expression (seven subexpressions)
以交互方式安装ESXi 6.0
The ninth Operation Committee meeting of dragon lizard community was successfully held