Hi, I have an array that has 4 indexes. When I user clicks on 1 of 4 possible buttons I have a script that sets the index to null. But I am at a loss for how to transfer that information using the On Click? I have set up 4 tags, 0,1,2,3 and convert the string names to int values to select the index.
public void deleteUsedItemFromPlayerArray(string name){
float cameraPos = Camera.main.transform.position.x;
bool isRight = (cameraPos > 0) ? true : false;
if(isRight){
print("Tag Number: " + name);
playerRArray[int.Parse(name)] = null;
}
else{
}
}
I instantiate the Button and assign the tag number depending on what index number it has in the array.
Button newBut = Instantiate(playerRArray[x], positionArrayInventory[x], Quaternion.identity) as Button;
newBut.transform.SetParent(playerRInventoryHolder.transform, false);
newBut.interactable = true;
newBut.transform.tag = x.ToString();
break;
I see default functions in the On Click of the button and one is GameObject.Tag but have no idea how to send that to my Method, if possible?
Thanks.