I am not sure why my code is not running the second IF statement in the list if the first is not true. I have a variable that is an enum that I am trying to check. If it is one value, then run the first IF statement, if its the next value then run the second. The first one works perfectly but when I change the enum variable to the second value it never gets to the second IF statement. Why is this? How do I fix it?
public void AddAttacks(Item item)
{
if (item.itemType == Item.ItemType.MainHand)
{
if (item.attack1 != null)
{
MainHandAttacks.Add(item.attack1);
GameObject attack1 = Instantiate(attackSlot, mainHandPanel.transform);
attack1.GetComponentInChildren<Text>().text = item.attack1.name;
attack1.GetComponent<AttackSlot>().attack = item.attack1;
attack1.GetComponent<AttackSlot>().SelectAttack();
}
}
if (item.itemType == Item.ItemType.OffHand)
{
if (item.attack1 != null)
{
OffHandAttacks.Add(item.attack1);
GameObject attack1 = Instantiate(attackSlot, offHandPanel.transform);
attack1.GetComponentInChildren<Text>().text = item.attack1.name;
attack1.GetComponent<AttackSlot>().attack = item.attack1;
}
}
}
from what I can see, if the first IF statement is true then it should move down to the next one and check. I have also tried setting it to an ELSE IF statement and that doesn’t change it at all. Any ideas?