public GameObject Find(Func <GameObject, bool> del) { if (iBox != null) { if (del.Invoke(IBox)) { return(IBox); } return(iBox.Find(del)); } return(null); }
/// <summary> /// Find an object among children with a given condition /// </summary> /// <param name="del"></param> /// <returns></returns> public virtual GameObject Find(Func <GameObject, bool> del) { if (inventory != null) { if (del.Invoke(inventory)) // Check if the inventory fits "del" { return(inventory); } GameObject invResult = inventory.Find(del); // Find the object matching "del" among the children of inventory if (invResult != null) { return(invResult); } } if (equipmentSlots != null) { if (del.Invoke(equipmentSlots)) // Check if equipmentSlots fits "del" { return(equipmentSlots); } GameObject eqResult = equipmentSlots.Find(del); // Find the object matching "del" among the children of equipmentSlots if (eqResult != null) { return(eqResult); } } if (skillList != null) { if (del.Invoke(skillList)) // Check if equipmentSlots fits "del" { return(skillList); } GameObject slResult = skillList.Find(del); // Find the object matching "del" among the children of equipmentSlots if (slResult != null) { return(slResult); } } return(null); }