//use for struct to lua public void NewUserDataWithGC(object o) { GCHandle handle = GCHandle.Alloc(o); IntPtr obj_ptr = GCHandle.ToIntPtr(handle); IntPtr ptr = LuaAPI.lua_newuserdata(this.m_lua, IntPtr.Size); Marshal.WriteIntPtr(ptr, obj_ptr); SetGCFunc(); }
private GCHandle NewUserData(object o) { GCHandle handle = GCHandle.Alloc(o); IntPtr obj_ptr = GCHandle.ToIntPtr(handle); IntPtr ptr = LuaAPI.lua_newuserdata(this.m_lua, IntPtr.Size); Marshal.WriteIntPtr(ptr, obj_ptr); return(handle); }