当前位置:网站首页>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);
}
}
边栏推荐
- NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
- Web API配置自定义路由
- How to understand super browser? What scenarios can it be used in? What brands are there?
- 修复动漫1K变8K
- Go language learning notes - first acquaintance with go language
- 边缘计算如何与物联网结合在一起?
- ibatis的动态sql
- Dspic33ep clock initialization program
- Huawei equipment configures channel switching services without interruption
- Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in
猜你喜欢

DDR4硬件原理图设计详解

7.2每日学习4

Stop saying that microservices can solve all problems!

Codeforces Round #804 (Div. 2)

Oneforall installation and use

Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
![[advertising system] incremental training & feature access / feature elimination](/img/14/ac596fa4d92e7b245e08cea014a4ab.png)
[advertising system] incremental training & feature access / feature elimination

Wechat nucleic acid detection appointment applet system graduation design completion (7) Interim inspection report

AUTOCAD——遮罩命令、如何使用CAD对图纸进行局部放大

How did the situation that NFT trading market mainly uses eth standard for trading come into being?
随机推荐
Basic part - basic project analysis
解决grpc连接问题Dial成功状态为TransientFailure
基于Lucene3.5.0怎样从TokenStream获得Token
7.2 daily study 4
【Oracle】使用DataGrip连接Oracle数据库
解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
高校毕业求职难?“百日千万”网络招聘活动解决你的难题
Leetcode 185 All employees with the top three highest wages in the Department (July 4, 2022)
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
如何通俗理解超级浏览器?可以用于哪些场景?有哪些品牌?
[Oracle] use DataGrid to connect to Oracle Database
Evolution of multi-objective sorting model for classified tab commodity flow
7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
边缘计算如何与物联网结合在一起?
Paradigm in database: first paradigm, second paradigm, third paradigm
项目总结笔记系列 wsTax KT Session2 代码分析
871. Minimum Number of Refueling Stops
基础篇——基础项目解析
Three paradigms of database