【Unity】AnimationのAnimationsを取得したい!
取得したい!
というわけで調べると、いつも調べ物でお世話になっているブログで発見。
この通りに書いてもエラーが!?
4年前ですから当然ですよね。
Uniity2017.3 での記述はこちら
private List<AnimationClip> animations = new List<AnimationClip>( );
void Start ( )
{
foreach (AnimationState anim in this.GetComponent<Animation>( ) )
{// リストに取得する
this.animations.Add( anim.clip );
}}
ちなみに呼び出すときは以下の文です。
GetComponent<Animation>( ).Play( this.animations[0].name );
明日も頑張りましょう!