From ca35784f96393ba408f50e39fa959ec091a81dea Mon Sep 17 00:00:00 2001 From: CH Date: Thu, 3 Dec 2020 14:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlua=E5=BC=BA=E8=A1=8Cget?= =?UTF-8?q?=E6=B2=A1=E6=9C=89getter=E7=9A=84=E5=B1=9E=E6=80=A7=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ToLua/Core/LuaState.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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) {