Hi,
I’m trying to create a function that reads a value contained in a button. If the value matches a value in a list, the button is supposed to disappear. It runs whenever the button is clicked (in the OnClick() field in the inspector). Unfortunately, I can’t figure out how to have the script reference the button and have it disable itself.
This is my code:
public void CheckIfARequiredItem()
{
string slotValue = gameObject.GetComponent<SlotValue>().value;
//see if the slot value is a required button
for (int i = 0; i < requiredItems.Length; i++)
{
if (slotValue == requiredItems[i].ToString())
{
//add the item to what has been collected
//and disable the button
itemsCollected.Add(requiredItems[i].ToString());
gameObject.SetActive(false);
}
}
}
Your help would be greatly appreciated!