public static void DoRefLuaFun(IntPtr L, string funName, int reference, LuaDLL.tolua_getref_fun refFun)
        {
            int moreOldTop = LuaDLL.lua_gettop(L);

            if (refFun == null)
            {
                LuaDLL.lua_getref(L, reference);
            }
            else
            {
                refFun(L, reference);
            }

            if (LuaDLL.lua_isfunction(L, -1) || LuaDLL.lua_istable(L, -1))
            {
                int oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "miku_handle_error");
                do
                {
                    LuaDLL.lua_getglobal(L, funName);
                    if (!LuaDLL.lua_isfunction(L, -1))
                    {
                        break;
                    }
                    LuaDLL.lua_pushvalue(L, oldTop);
                    if (LuaDLL.lua_pcall(L, 1, 0, oldTop + 1) == 0)
                    {
                        LuaDLL.lua_remove(L, oldTop + 1);
                    }
                } while (false);
                LuaDLL.lua_settop(L, oldTop);
            }

            LuaDLL.lua_settop(L, moreOldTop);
        }
 public static void HookUnRef(IntPtr L, int reference, LuaDLL.tolua_getref_fun refFun = null)
 {
     if (isHook)
     {
         LuaLib.DoRefLuaFun(L, "lua_miku_remove_ref_fun_info", reference, refFun);
     }
 }