Here is the code being use:
private void start()
{
for (int i = 0; i < 5; i++)
{
GameObject card = Instantiate(deck[i], playersHandContent.transform);
card.GetComponent<Button>().onClick.AddListener(delegate { AddCardToUse(card); });
}
}
void AddCardToUse(GameObject cardSelected)
{
Debug.Log(cardSelected.name);
cardsSelected.Append(cardSelected);
}
I current calling a function when a card is clicked in the Unity UI. The card name is correct so it know its finding the object but when I attempt to append the GameObject to an array the error: "ArgumentNullException: Value cannot be null. Parameter name: source" appears. I am just trying to add the object to the array. Currently the system instantiates the object and adds a listener for the function below to add append it to an array, or atleast thats what I want it to do. I have no idea why im getting this issue as I've never encountered it in unity before.
SO far I have tried diffrent ways to get the GameObject though the button but all result in this out come. One version I tried was using this to get the object: UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject Even this way I still get the same reult
This also produced the same error: card = selectedCard; cardsSelected.Append(card); also give the same result
cardsSelectedisnull... yesterday I saw the same question posted on a different account ... could you stick to that one please? ;) Also add enough details to reproduce your issue .. we don't see whatcardsSelectedselected even is ... but if it is still an array (as the last time) then I can only repeat @BugFinder 's question: Why is this still not aListif you are going to extend it on runtime?