public void DespawnNPC(string NPCName)
{
Debug.Log(NPCName); //This prints in console normally, string verified to be correct.
for (int i = 0; i < sceneNPCData.Count; i++) //This doesn't run through LUA but runs otherwise.
{
if (sceneNPCData[i].NPCName == NPCName)
{
Debug.Log("NPC Name Match found in list of scene NPC. Despawning +" + NPCName + "On screen fade.");
sceneNPCData[i].gameObject.AddComponent<ObjectDespawner>();
sceneNPCData[i].gameObject.GetComponent<ObjectDespawner>().SubscribeToFader();
break;
}
}
}
I solved the problem by changing the LUA method registration from Awake() to Start(), but I'm wondering why it was happening as I would like to avoid running into an issue like this later on.
Bah! I found the problem. I tried the debug stuff you mentioned but I realized it's because I had forgotten to add the UnresgisterFunction OnDisable(). During testing, I was changing scenes and I'm guessing the same LUA function was registering twice without ever being removed. I'm not sure at what point I ended up adding the OnDisable but it must have been when I was trying out the switch from Awake to Start since it's working as intended on both of them now.
Is there anywhere to check which LUA functions are registered at any given time or is that something not visible? In any case, thanks for the help!
It's not visible. They get added as if they're native Lua functions, so it doesn't distinguish them from built-in Lua functions such as math.sqrt() and string.lower(). You can, however, manually keep track of your own Lua functions that you've registered. Example: