LoginSignup
11
9

More than 5 years have passed since last update.

Unityでアニメーションの状態を確認する

Posted at

特定のClipの再生が始まったらなにがしかの処理をしたい、みたいなときのチェック方法。

bool isReady = GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).shortNameHash.Equals(Animator.StringToHash("Clipの名前"));

もしくは

bool isReady = GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).IsName("レイヤー名.Clipの名前");

でチェックできる。
前者はClipの名前だけでよくて、後者はレイヤーの名前も必要となる。

尚、レイヤーの名前はAnimatorウィンドウに表示されている。
スクリーンショット 2016-01-18 午後3.43.00.png
この画像でいうと「Base Layer」がこれに該当するので、IsNameメソッドを利用する場合、「Base Layer.Clip名」という風に指定をするような形になる。

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9