For example I have a gameObject that has following code:
Code: Select all
void OnEnable() {
Lua.RegisterFunction("AddItem", this, SymbolExtensions.GetMethodInfo(() => addItem(string.Empty, (double)0)));
Lua.RegisterFunction("HasItem", this, SymbolExtensions.GetMethodInfo(() => hasItem(string.Empty, (double)0)));
}
void OnDisable() {
Lua.UnregisterFunction("AddItem");
Lua.UnregisterFunction("HasItem");
}
When I load another scene and the Dialogue system needs to access this method, I get following stack:
Code: Select all
Dialogue System: Lua code 'return CurrentQuestState("GrowCorn") == "active" and HasItem("CORN",5) == false' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:IsTrue(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:EvaluateLinksAtPriority(ConditionPriority, DialogueEntry, List`1, List`1, List`1, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:EvaluateLinks(DialogueEntry, List`1, List`1, List`1, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle()
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle()
PixelCrushers.DialogueSystem.Sequencer:FinishSequence()
PixelCrushers.DialogueSystem.Sequencer:Update()
What am I doing wrong?