Browse Source

Handle case when a type fails to register in MoonSharp

master
Chris Gregan 9 years ago
parent
commit
6d90fecffb
  1. 26
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs

26
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs vendored

@ -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;

Loading…
Cancel
Save