@daaoling
2017-02-28T00:27:35.000000Z
字数 1056
阅读 3423
Unity
toLua
热更新
一直以来对lua 和 c# 交互的原理挺好奇的,我知道的就是lua 有c api, 但是基于 C# 该如何交互我就很好奇了。
现在热更新的方案基本无外乎就是tolua,slua,xlua, 我决定追根溯源一下, 据我了解, 其历史版本为早期的ulua(luainterface) => cstolua => tolua.
首先就要说一下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.
class UnityEngine.AnimationClip
{
public float frameRate;
public void AddEvent (AnimationEvent evt);
}
public class UnityEngine_AnimationClipWrap
{
public static void Register(LuaState L)
{
L.BeginClass(typeof(UnityEngine.AnimationClip), typeof(UnityEngine.Object));
L.RegFunction("AddEvent", AddEvent);
L.RegVar("frameRate", get_frameRate, set_frameRate);
L.EndClass();
}
}
A = { AddEvent = AddEvent
&gettag = {frameRate = get_frameRate},
&settag = {frameRate = set_frameRate} }
when get frameRate through class_index_event and set frameRate through class_newindex_event