diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs index 18502475..95dc5dfe 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs @@ -184,14 +184,21 @@ namespace Fungus if (!UserData.IsTypeRegistered(t)) { - if (extensionType) - { - UserData.RegisterExtensionType(t); - } - else - { - UserData.RegisterType(t); - } + try + { + if (extensionType) + { + UserData.RegisterExtensionType(t); + } + else + { + UserData.RegisterType(t); + } + } + catch (ArgumentException ex) + { + UnityEngine.Debug.LogWarning(ex.Message); + } } } @@ -215,7 +222,8 @@ namespace Fungus LogException(ex.DecoratedMessage, luaString); } - if (res.Type != DataType.Function) + if (res == null || + res.Type != DataType.Function) { UnityEngine.Debug.LogError("Failed to create Lua function from Lua string"); return null;