Search Unity

IAnimationClipSource : how does it work?

Discussion in 'Animation' started by ReadyPlayGames, Jan 11, 2019.

  1. ReadyPlayGames

    ReadyPlayGames

    Joined:
    Jan 24, 2015
    Posts:
    30
    Going through the release notes for 2018.3, I am trying to get examples working of all of the changes. I don't know how to get IAnimationClipSource to work.

    Here is my naive example (just add clips to the list in the inspector):

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class AnimationClipPreviewer : MonoBehaviour , IAnimationClipSource{
    5.     public List<AnimationClip> clipList;
    6.     public void GetAnimationClips(List<AnimationClip> results) {
    7.         results = clipList;
    8.     }
    9. }
    Nothing shows up in the Animator window, yet it DOES trigger when the window is focused. How do we use this function?
     
  2. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    222
    results isn't an out parameter so reassigning it will do nothing. Try using results.AddRange(clipList).
     
  3. ReadyPlayGames

    ReadyPlayGames

    Joined:
    Jan 24, 2015
    Posts:
    30
    Yep, that did it! I wonder if this is the intended way to use this, though.
     
  4. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    222
    What do you mean? If it worked then that's the way to use it. Your original way was wrong because of how C# works, not due to any odd quirk of Unity's system.
     
  5. ReadyPlayGames

    ReadyPlayGames

    Joined:
    Jan 24, 2015
    Posts:
    30
    I mean if I'm supposed to keep a list of Animation clips or not. But you're right, if it works it works!