So I have this code block.
private void PopulateAnswerBoxItems(int charID, EventPackage packet)
{
for(int i = 0; i< packet.listOfAnswers.Count;i++)
{
GameObject answer = Instantiate(answerItem);
answer.GetComponent<UI_EventResolutionPackage>().AssignData(packet.listOfAnswers*);*
Button attached = answer.GetComponentInChildren();
attached.onClick.AddListener(() => PopulateFinalDescriptors(charID, packet.listOfAnswers*));*
attached.onClick.AddListener(() => SetActiveScreen(1));
listOfAnswers.Enqueue(answer);
answer.transform.SetParent(answersBox.transform);
answer.transform.localScale = Vector3.one;
}
}
When I click on the end result (a button), it throws an ArgumentOutOfRange Exception at the first onClick.AddListener line.
the charID is valid, the button I’m clicking on is valid, the EventPackage is valid (not null), the list of answers is valid (all not null)…I don’t know why it’s doing this.
I’m not really looking for a solution per se, I just want to know where I should look next to solve this issue.
This is the error message.
[79506-question.png|79506]_
_