LoginSignup
14
12

More than 5 years have passed since last update.

Unityで再生しているアニメーションをスキップする方法

Last updated at Posted at 2014-03-10

@yomogi_ft さんからおしえてもらった方法の備忘録

主に↓を使うとかの話
http://docs.unity3d.com/Documentation/ScriptReference/Animation.html

Unityで演出にAnimationを使っていてスキップする方法がぱっと見つからなかったので聞いてみたらススッと答えが返って来てコレが上手く動いてくれたのでシェア(掲載許可はもらいずみ)

なおMecanim のAnimatorだと使えないのでご注意。

SkipCurrentAnimation.cs
void SkipCurrentAnimation()
 {
  // 現在再生中のアニメーションクリップ名を取得
  // もっとよい方法があれば...
  var clipName = "";
  foreach(AnimationState state in this.animation) {
   if (this.animation.IsPlaying(state.name)) {
    clipName = state.name;
    break;
   }
  }

  //clipNameが現在の再生クリップと一致していればうまいこと動作する
  this.animation[clipName].time = this.animation.GetClip(clipName).length;
 }

超カンタンにできたのでもし同じ事やろうとして見つからなかった人は是非。
あとこの方法だとこういう問題あるよ!!とかあればだれか突っ込んくださいm(_ _)m

ではでは٩( 'ω' )و

14
12
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
14
12