1.Animatorウィンドウで、以下の状態を作り出しておく。
※左のパラメータは、Parametersタブ / +をクリックし、Triggerを選択。
2.New Stateからget@ImageMokugyoの矢印をクリックし、遷移するトリガーを「isGetScore」を設定する。
※Has Exit Timeをオフにすることで、直ちに遷移される。
3.スクリプトは以下の通り。
// オーブ入手 public void GetOrb(int getScore) { audioSource.PlayOneShot(getScoreSE); // AnimatorStateInfoオブジェクトの取得 AnimatorStateInfo stateInfo = imageMokugyo.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0); // get@ImageMokugyoが再生中だったら if(stateInfo.fullPathHash == Animator.StringToHash("Base Layer.get@ImageMokugyo")) { // 最初から再生 imageMokugyo.GetComponent<Animator>().Play(stateInfo.fullPathHash, 0, 0.0f); } else { // isGetScoreをオンにする imageMokugyo.GetComponent<Animator>().SetTrigger("isGetScore"); } if (score < nextScore) { score += getScore; if (score > nextScore) { score = nextScore; } TempleLevelUp(); RefreshScoreText(); imageTemple.GetComponent<TempleManager>().SetTempleScale(score, nextScore); if ((score == nextScore) && (templeLevel == MAX_LEVEL)) { ClearEffect(); } } currentOrb--; }