を着色するためのコードである を選択しています。それらをcurrentlySelectedIndex
とpreviouslySelectedIndex
と呼ぶことができます。
以前に選択された領域がないため、これらの2つは最初のオブジェクトを指しています。
2回目以降の選択を行うと、currentlySelectedIndex
は新たに選択された領域にアサインされますが、previouslySelectedIndex
は引き続き古い領域を指します。
この時点で、領域を塗りつぶしたときのようにpreviouslySelectedIndex
を使用します。古い領域の塗りつぶしが完了したら、previouslySelectedIndex
をcurrentlySelectedIndex
と割り当てます。そしてこれは続くでしょう。
擬似
//Check if its the first time Selection
currentlySelectedIndex = System.Array.IndexOf(Maps, target);
Maps[currentlySelectedIndex].GetComponent<SpriteRenderer>().color = Color.gray;
previouslySelectedIndex = currentlySelectedIndex;
//After the first time selection
currentlySelectedIndex = System.Array.IndexOf(Maps, target); //New Selected Region
Maps[currentlySelectedIndex].GetComponent<SpriteRenderer>().color = Color.gray;
Maps[previouslySelectedIndex].GetComponent<SpriteRenderer>().color = FadeColor; //Old Selected Region
previouslySelectedIndex = currentlySelectedIndex;
あなたは地域の色が別の選択した色にグレーからlerpしたいと言っていますか? – oxrock