public static void PushValue(IntPtr L, ValueType v) { if (v == null) { LuaDLL.lua_pushnil(L); return; } Type type = v.GetType(); int reference = LuaStatic.GetMetaReference(L, type); ObjectTranslator translator = ObjectTranslator.Get(L); if (reference > 0) { int index = translator.AddObject(v); LuaDLL.tolua_pushnewudata(L, reference, index); } else { LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type); if (LuaOpenLib != null) { #if UNITY_EDITOR lhDebug.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type)); #endif LuaOpenLib(L); reference = LuaStatic.GetMetaReference(L, type); if (reference > 0) { int index = translator.AddObject(v); LuaDLL.tolua_pushnewudata(L, reference, index); return; } } //类型未Wrap LuaDLL.lua_pushnil(L); lhDebug.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type)); } }
static void PushPreLoadType(IntPtr L, object o, Type type) { LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type); if (LuaOpenLib != null) { #if UNITY_EDITOR lhDebug.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type)); #endif LuaPCall(L, LuaOpenLib); int reference = LuaStatic.GetMetaReference(L, type); if (reference > 0) { PushUserData(L, o, reference); return; } } //类型未Wrap LuaDLL.lua_pushnil(L); lhDebug.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type)); }