Lua code threw exception 'Exception has been thrown by the target of an invocation.'
Posted: Sat Mar 03, 2018 2:51 am
I've registered a C# method as lua in a script to instantiate a prefab as a child UI gameobject, through the sequencer. This is how I register it -
In the Dialogue entry tab, I've called SpEOC1() method in "Sequence" and "Scripts" fields for a specific NPC dialogue.
But this is the error I get -
Dialogue System: Lua code 'SpEOC1()' threw exception 'Exception has been thrown by the target of an invocation.'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry)
PixelCrushers.DialogueSystem.ConversationController:OnSelectedResponse(Object, SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.ConversationView:SelectResponse(SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.ConversationView:OnSelectedResponse(Object, SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnClick(Object)
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
PixelCrushers.DialogueSystem.UnityUIResponseButton:OnClick() (at Assets/Dialogue System/Scripts/Supplemental/UI/Dialogue UI/UnityUIResponseButton.cs:174)
UnityEngine.EventSystems.EventSystem:Update()
Because of this error, the prefab doesn't instantiate at all but the dialogue system continues gameplay as if nothing happened.
There are 3 cloned scenes using the same dialogue manager. I've heard having multiple dialogue managers in different scenes causes problems. But removing the cloned scenes here is not possible due to how the game was designed by the previous programmer.
Strangely, the instantiation was working a while ago before I made a few other changes, so I know there's nothing wrong with the prefab or the code.
Could somebody please enlighten me on what's happening? Specifically, what does this invocation error mean? -
Lua code 'SpEOC1()' threw exception 'Exception has been thrown by the target of an invocation.'
Code: Select all
Lua.RegisterFunction("SpEOC1", this, typeof(SpawnDivider).GetMethod("SpawnEOC1"));
public void SpawnEOC1()
{
GameObject Div = (GameObject)Instantiate(EOC1, Scroll.transform);
}
But this is the error I get -
Dialogue System: Lua code 'SpEOC1()' threw exception 'Exception has been thrown by the target of an invocation.'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry)
PixelCrushers.DialogueSystem.ConversationController:OnSelectedResponse(Object, SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.ConversationView:SelectResponse(SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.ConversationView:OnSelectedResponse(Object, SelectedResponseEventArgs)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnClick(Object)
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
PixelCrushers.DialogueSystem.UnityUIResponseButton:OnClick() (at Assets/Dialogue System/Scripts/Supplemental/UI/Dialogue UI/UnityUIResponseButton.cs:174)
UnityEngine.EventSystems.EventSystem:Update()
Because of this error, the prefab doesn't instantiate at all but the dialogue system continues gameplay as if nothing happened.
There are 3 cloned scenes using the same dialogue manager. I've heard having multiple dialogue managers in different scenes causes problems. But removing the cloned scenes here is not possible due to how the game was designed by the previous programmer.
Strangely, the instantiation was working a while ago before I made a few other changes, so I know there's nothing wrong with the prefab or the code.
Could somebody please enlighten me on what's happening? Specifically, what does this invocation error mean? -
Lua code 'SpEOC1()' threw exception 'Exception has been thrown by the target of an invocation.'