如何重构这么大的if条件?武器是一张单子,它;s游戏对象
如何重构这么大的if条件?武器是一张单子,它;s游戏对象
public class Customanger : MonoBehaviour
{
public List<GameObject> weapon;
public static Customanger singleton;
private void Awake() => singleton = this;
};
if (Customanger.singleton.weapon[1].activeSelf ||
Customanger.singleton.weapon[2].activeSelf ||
Customanger.singleton.weapon[3].activeSelf ||
Customanger.singleton.weapon[4].activeSelf ||
Customanger.singleton.weapon[5].activeSelf ||
Customanger.singleton.weapon[8].activeSelf ||
Customanger.singleton.weapon[10].activeSelf ||
Customanger.singleton.weapon[12].activeSelf ||
Customanger.singleton.weapon[13].activeSelf ||
Customanger.singleton.weapon[14].activeSelf ||
Customanger.singleton.weapon[15].activeSelf ||
Customanger.singleton.weapon[16].activeSelf ||
Customanger.singleton.weapon[17].activeSelf)
{
dosomething();
}