43
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UnityでAnimationControllerをscriptから指定する

Last updated at Posted at 2014-02-27

Unityでanimation clipの中のsprite画像を動的に指定したい。

例えば、walkモーションの動きは同じで表示する画像だけ変えたい!
がやり方がわからなかったので、A@walk, B@walkみたいに
animation clipとanimation controllerをそれぞれつくって
animation controllerをscriptで動的に指定できないかやってみた。

用意したもの

Resouces/Animations/A.controller
Resouces/Animations/A@walk.anim
Resouces/Animations/B.controller
Resouces/Animations/B@walk.anim

script内から下記のようにanimation contollerの指定したら動いた!

void Start() {
  animator = GetComponent<Animator>();
  animator.runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load ("path/to/controller_file"));
}

コントローラー同じで表示する画像だけ変える方法を見つけたい。。。

43
26
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
43
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?