Weird problem with LUA running partial method?
Posted: Thu Jun 03, 2021 11:57 am
Hello, I'm trying to wrap my head around this. I seem to have fixed the issue but I don't understand why it was happening.
For some reason, when I tried to execute this method through LUA, it would only run until the first debug log and never do the rest of the loop.
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.
For some reason, when I tried to execute this method through LUA, it would only run until the first debug log and never do the rest of the loop.
Code: Select all
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;
}
}
}