Search Unity

Animation type changed from Generic to Legacy; animation clips now irretrievable

Discussion in 'Scripting' started by MiaoBolverk, Nov 22, 2018.

  1. MiaoBolverk

    MiaoBolverk

    Joined:
    Feb 6, 2018
    Posts:
    26
    I imported an .fbx file with the 19 animation clips:


    Originally, the animation type is Generic, with the following properties:



    I change the animation type to Legacy, because I want to be able to sample animation clips at specific lengths during runtime, e.g. by writing code like this:

    Code (csharp):
    1. this.animationClip.SampleAnimation(this.animatedGameObject, this.someValue * this.animationClip.length)
    I have experimented with all animation types, and Legacy is the only one that allows me to manipulate animations through code. For that reason, I changed the animation type of my .fbx file to the following:



    Ideally, after changing the animation type to Legacy, I should be seeing the following:



    However, Unity claims that there are no animation clips:


    Fortunately, I use source control, and so I am able to figure out exactly which commit caused the undesirable behaviour.

    It turns out that, when the animated game object is NOT a prefab instance, all the animation clips are displayed correctly, even in Legacy mode.

    In the commit which caused the undesirable behaviour, a prefab of the animated game object was created, and multiple instances of the prefab were then added to the scene. Changing the animation type of the .fbx file now resulted in the inspector's failure to display the animation clips when I click on an instance of the prefab, even though all clips are still being referenced inside the .fbx.meta file.

    How can I fix, or work around, this issue? I absolutely need to be able to sample animation clips as I see fit during runtime, and as far as I know, the Legacy animation type is the only one allowing me to do this. Unfortunately, changing the animation type on the .fbx file causes the animation clips to be irretrievable, seemingly because game objects that reference the .fbx file are prefab instances.
     
  2. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    The Legacy animation system uses the Animation component, the 'new' one uses the Animator component. You mention creating prefabs, sound's to me you have different objects that mismatch.
    If you're not running 2018.3 with nested prefabs, sounds like you made your changes to the fbx importer after having created a prefab prior to that, so the changes to the fbx imported object would not reflect over to the custom prefab.
    So you maybe just have to recreate the prefab from the fbx.