bool OnOven(GameObject plate, Transform parent) { bool isPlate = false; if (parent != null) { if (parent.GetComponent <HotPlateOven>()) { HotPlateOven hotPlateOven = parent.GetComponent <HotPlateOven>(); for (int i = 0; i < hotPlateOven.plates.Length; i++) { if (hotPlateOven.plates[i].name == plate.name && hotPlateOven.activePlateIndices[i]) { isPlate = true; return(isPlate); } } } } return(isPlate); }
bool OnOven(Transform parent) { bool isPlate = false; while (parent != null) { if (parent.GetComponent <HotPlateOven>()) { HotPlateOven hotPlateOven = parent.GetComponent <HotPlateOven>(); for (int i = 0; i < hotPlateOven.plates.Length; i++) { if (hotPlateOven.plates[i].name == firstCollidedObject.name && hotPlateOven.activePlateIndices[i]) { isPlate = true; return(isPlate); } } } parent = parent.transform.parent; } return(isPlate); }