8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IAnimationClipSourceという神インターフェースについて

Last updated at Posted at 2026-01-16

Unityでアニメーションを使うとき、こんな経験ありませんか?

  • 背景に簡単なループアニメを設定したいだけなのに…
    AnimationClip作って、わざわざ1対1でAnimatorControllerも作らなきゃいけないのメンドすぎて死ぬぅ
  • Playable APIで頑張ってAnimatorControllerを回避したのに…
    → 結局AnimationClipを編集しようと思ったらまたAnimatorControllerが必要になって草

その煩わしさ、実は簡単に解決できます

答えは → IAnimationClipSource です!

公式ドキュメント

超絶簡単な実装例

SimpleAnimation.cs
public class SimpleAnimation : MonoBehaviour,IAnimationClipSource
{  
    //Animationウィンドウに対応させたいアニメーションクリップ
    [SerializeField]
    AnimationClip[] clips;
    
    void IAnimationClipSource.GetAnimationClips(List<AnimationClip> results)
    {
        foreach(var clip in clips)
            results.Add(clip);
    }
}  

使い方は超簡単
任意のMonoBehaviourIAnimationClipSourceを継承し、GetAnimationClips()を実装。
引数で渡されるList<AnimationClip>に好きなAnimationClipをAddするだけです。

あとはこのスクリプトとAnimatorを同じGameObjectにアタッチすればこの通り。

SimpleAnimation.png

Animatorに対してAnimatorControllerを設定しなくてもAnimationWindowで先のスクリプトで受け渡したAnimationClipを選択、編集、プレビュー可能になります。

Playable APIを用いたAnimationの再生の実装については既に記事が沢山存在するためここでは説明しません。

それではよきUnityライフを。

8
5
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
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?