当前位置:网站首页>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);
}
}
边栏推荐
- COMSOL -- establishment of 3D graphics
- What does cross-border e-commerce mean? What do you mainly do? What are the business models?
- 【Oracle】使用DataGrip连接Oracle数据库
- SLAM 01. Modeling of human recognition Environment & path
- [office] eight usages of if function in Excel
- Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
- NFT 交易市场主要使用 ETH 本位进行交易的局面是如何形成的?
- 我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
- DDR4硬件原理图设计详解
- Paradigm in database: first paradigm, second paradigm, third paradigm
猜你喜欢

Stop saying that microservices can solve all problems!

7.2 daily study 4

Summary of thread and thread synchronization under window

R3Live系列学习(四)R2Live源码阅读(2)
![[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output](/img/96/b8585205b3faf503686c5bbdcecc53.png)
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output

Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022

Advanced technology management - what is the physical, mental and mental strength of managers

2022 t elevator repair operation certificate examination questions and answers

Basic testing process of CSDN Software Testing Introduction

Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
随机推荐
Msfconsole command encyclopedia and instructions
msfconsole命令大全,以及使用说明
COMSOL -- 3D casual painting -- sweeping
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
ibatis的动态sql
spark调优(一):从hql转向代码
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
无密码身份验证如何保障用户隐私安全?
Three paradigms of database
SSL证书错误怎么办?浏览器常见SSL证书报错解决办法
[JS learning notes 54] BFC mode
Beego cross domain problem solution - successful trial
我用开天平台做了一个城市防疫政策查询系统【开天aPaaS大作战】
COMSOL--三维随便画--扫掠
【爬虫】wasm遇到的bug
comsol--三维图形随便画----回转
Stop saying that microservices can solve all problems!
力扣(LeetCode)185. 部门工资前三高的所有员工(2022.07.04)
如何通俗理解超级浏览器?可以用于哪些场景?有哪些品牌?
Home office things community essay