カードを Y 軸を中心に時間内に回転させるクラス Card の関数を作成しました。
public IEnumerator RotateCard(float angle)
{
if(rotating)
yield break;
rotating = true;
float newAngle = curRotation.y + angle;
while(curRotation.y < newAngle)
{
curRotation.y = Mathf.MoveTowards(curRotation.y, newAngle, rotateSpeed * Time.deltaTime);
transform.eulerAngles = curRotation;
yield return null;
}
rotating = false;
}
そして、Card.OnMouseDown() でこの関数を呼び出す必要があります。
IEnumerator OnMouseDown()
{
print ("Card clicked");
yield return StartCoroutine( RotateCard(180));
yield return StartCoroutine(gameManager.actionDeck[0].RotateCard(180));
}
ここで、gameManager はカード actionDeck のリストを含むオブジェクトです。
最初の呼び出しは、その関数が行うべきことを実行します - Card を Y 軸を中心に回転させます。
一方、2 番目の呼び出しでは、Card が奇妙なポイントを中心に回転します。
呼び出し#1と同じように機能させる理由と方法はありますか?