当前位置:网站首页>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);
}
}
边栏推荐
- ibatis的动态sql
- 我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
- [advertising system] parameter server distributed training
- 技术管理进阶——什么是管理者之体力、脑力、心力
- An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
- -26374 and -26377 errors during coneroller execution
- 基于Lucene3.5.0怎样从TokenStream获得Token
- 2022 t elevator repair operation certificate examination questions and answers
- Four departments: from now on to the end of October, carry out the "100 day action" on gas safety
- How to introduce devsecops into enterprises?
猜你喜欢

MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
![[Oracle] use DataGrid to connect to Oracle Database](/img/4f/886378667889f730eaed39b97f0a39.png)
[Oracle] use DataGrid to connect to Oracle Database

【Oracle】使用DataGrip连接Oracle数据库

Three suggestions for purchasing small spacing LED display

【爬虫】wasm遇到的bug

In the last process before the use of the risk control model, 80% of children's shoes are trampled here

Huawei equipment configures channel switching services without interruption

Intelligent metal detector based on openharmony

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

华为设备配置信道切换业务不中断
随机推荐
Huawei equipment configures channel switching services without interruption
基于Lucene3.5.0怎样从TokenStream获得Token
OneForAll安装使用
NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
spark调优(一):从hql转向代码
c#操作xml文件
7.2 daily study 4
Go language learning notes - first acquaintance with go language
【Oracle】使用DataGrip连接Oracle数据库
Sklearn model sorting
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
COMSOL--三维图形的建立
Repair animation 1K to 8K
Go language learning notes - analyze the first program
[SWT component] content scrolledcomposite
CDGA|数据治理不得不坚持的六个原则
2022 t elevator repair operation certificate examination questions and answers
【全网首发】(大表小技巧)有时候 2 小时的 SQL 操作,可能只要 1 分钟
Paradigm in database: first paradigm, second paradigm, third paradigm
解决grpc连接问题Dial成功状态为TransientFailure