public static Func <IntPtr, int> GetLuaReference(Type type)
{
int metaref = -1;
return((IntPtr L ) =>
{
#if MULTI_STATE
return LuaStatic.GetMetaReference(L, type);
#else
if (metaref > 0)
{
return metaref;
}
metaref = LuaStatic.GetMetaReference(L, type);
if (metaref > 0)
{
LuaState.Get(L).OnDestroy += () => { metaref = -1; };
}
return metaref;
#endif
});
}