diff --git a/Assets/ToLua/Core/LuaState.cs b/Assets/ToLua/Core/LuaState.cs index 9880d29d..c00a78db 100644 --- a/Assets/ToLua/Core/LuaState.cs +++ b/Assets/ToLua/Core/LuaState.cs @@ -495,15 +495,19 @@ public void RegFunction(string name, LuaCSFunction func) LuaDLL.tolua_function(L, name, fn); } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + public static int InvalidPropertyGetter(IntPtr L) + { + throw new LuaException("InvalidPropertyGetter !"); + } + public void RegVar(string name, LuaCSFunction get, LuaCSFunction set) { IntPtr fget = IntPtr.Zero; IntPtr fset = IntPtr.Zero; - if (get != null) - { - fget = Marshal.GetFunctionPointerForDelegate(get); - } + fget = Marshal.GetFunctionPointerForDelegate(get != null ? get : InvalidPropertyGetter); if (set != null) {