Browse Source

Handle case when a type fails to register in MoonSharp

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

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

@ -183,6 +183,8 @@ namespace Fungus
} }
if (!UserData.IsTypeRegistered(t)) if (!UserData.IsTypeRegistered(t))
{
try
{ {
if (extensionType) if (extensionType)
{ {
@ -193,6 +195,11 @@ namespace Fungus
UserData.RegisterType(t); UserData.RegisterType(t);
} }
} }
catch (ArgumentException ex)
{
UnityEngine.Debug.LogWarning(ex.Message);
}
}
} }
/// <summary> /// <summary>
@ -215,7 +222,8 @@ namespace Fungus
LogException(ex.DecoratedMessage, luaString); 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"); UnityEngine.Debug.LogError("Failed to create Lua function from Lua string");
return null; return null;

Loading…
Cancel
Save