[关闭]
@daaoling 2017-02-27T16:27:35.000000Z 字数 1056 阅读 3364

Unity toLua 热更新

LuaInterface 到 ToLua 源码解读笔记

一直以来对lua 和 c# 交互的原理挺好奇的,我知道的就是lua 有c api, 但是基于 C# 该如何交互我就很好奇了。

现在热更新的方案基本无外乎就是tolua,slua,xlua, 我决定追根溯源一下, 据我了解, 其历史版本为早期的ulua(luainterface) => cstolua => tolua.

LuaInterface

首先就要说一下luainterface
LuaInterface

LuaInterface is a library for integration between the Lua language and Microsoft .NET platform's Common Language Runtime (CLR). 
Lua scripts can use it to instantiate CLR objects, access properties, call methods, and even handle events with Lua functions.

cstolua

tolua

  1. class UnityEngine.AnimationClip
  2. {
  3. public float frameRate;
  4. public void AddEvent (AnimationEvent evt);
  5. }
  6. public class UnityEngine_AnimationClipWrap
  7. {
  8. public static void Register(LuaState L)
  9. {
  10. L.BeginClass(typeof(UnityEngine.AnimationClip), typeof(UnityEngine.Object));
  11. L.RegFunction("AddEvent", AddEvent);
  12. L.RegVar("frameRate", get_frameRate, set_frameRate);
  13. L.EndClass();
  14. }
  15. }
  16. A = { AddEvent = AddEvent
  17. &gettag = {frameRate = get_frameRate},
  18. &settag = {frameRate = set_frameRate} }
  19. when get frameRate through class_index_event and set frameRate through class_newindex_event

slua

xlua

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注