Keep Getting TargetParameterCountException When Updating to U2021.2
Posted: Thu Apr 07, 2022 4:27 pm
I have just had to pick back up an old project which I was using U2018 for and it was working fine in there but I have updated to U2021 and re-installed the Dialogue Manager and a few other bits, everything compiles and runs fine but every time I try to interact (via proxy selector and use) it blows up with TargetParameterCountExceptions.
There are a few others similar to this, and while my first thought was "oh thats my method and its wrong" it basically does:
The odd thing is I can see when I enter the scene it runs this code, and it works fine, no errors, however I speak to anyone and it blows up.
Hopefully I am being an idiot or there is some simple fix but struggling to debug whats going on as its all down to reflection calls.
Code: Select all
TargetParameterCountException: Number of parameters specified does not match the expected number.
System.Reflection.RuntimeMethodInfo.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <47ab72e0328040438980f9c23608e1ec>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <47ab72e0328040438980f9c23608e1ec>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <47ab72e0328040438980f9c23608e1ec>:0)
Language.Lua.LuaMethodFunction.InvokeMethod (Language.Lua.LuaValue[] args) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Interpreter/LuaValue/LuaMethodFunction.cs:35)
Code: Select all
Dialogue System: Lua code 'return IsTimeAfter("18:02") == true' threw exception 'Number of parameters specified does not match the expected number.'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:228)
Code: Select all
// in an MB somewhere
Lua.RegisterFunction("IsTimeAfter", this, SymbolExtensions.GetMethodInfo(() => this.IsTimeAfter(String.Empty)));
// In another file somewhere
public static bool IsTimeAfter(this IHasGameState hasState, string time)
{
var proposedTime = time.GetProposedTime();
var effectiveTime = hasState.GameState.GetEffectiveTime();
return effectiveTime > proposedTime;
}
Hopefully I am being an idiot or there is some simple fix but struggling to debug whats going on as its all down to reflection calls.