4 つのボタンがあり、ボタンを押すとそれぞれが点滅します。ただし、ボタンを押す場合、ボタンが暗い (点滅している) 間に別のボタンをクリックすると、そのボタンは暗いままになります。無効にする前にスプライトの色をリセットしたいのですが、うまくいきません。ボタンを押しても点滅しなくなりました....
コードは次のとおりです。
void Start () {
easy.GetComponent<SpriteRenderer>().color = color;
}
void Update () {
if(difficultySelected[0] == true){
enemyBehavior.shotsPerSecond = 0.2f;
//Enabling the selected button
easy.enabled = true;
//Reseting the colors
normal.GetComponent<SpriteRenderer>().color = color;
hard.GetComponent<SpriteRenderer>().color = color;
expert.GetComponent<SpriteRenderer>().color = color;
//Disabling the 'unselected' buttons
normal.enabled = false;
hard.enabled = false;
expert.enabled = false;
easy.Play("Difficulty");
}else if(difficultySelected[1] == true){
enemyBehavior.shotsPerSecond = 0.5f;
normal.enabled = true;
easy.GetComponent<SpriteRenderer>().color = color;
hard.GetComponent<SpriteRenderer>().color = color;
expert.GetComponent<SpriteRenderer>().color = color;
easy.enabled = false;
hard.enabled = false;
expert.enabled = false;
normal.Play("Difficulty");
}else if(difficultySelected[2] == true){
enemyBehavior.shotsPerSecond = 1;
hard.enabled = true;
easy.GetComponent<SpriteRenderer>().color = color;
normal.GetComponent<SpriteRenderer>().color = color;
expert.GetComponent<SpriteRenderer>().color = color;
easy.enabled = false;
normal.enabled = false;
expert.enabled = false;
hard.Play("Difficulty");
}else if(difficultySelected[3] == true){
enemyBehavior.shotsPerSecond = 2;
expert.enabled = true;
easy.GetComponent<SpriteRenderer>().color = color;
normal.GetComponent<SpriteRenderer>().color = color;
hard.GetComponent<SpriteRenderer>().color = color;
easy.enabled = false;
normal.enabled = false;
hard.enabled = false;
expert.Play("Difficulty");
}
}