Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

SimpleAnimation doesn't play animation in release builds

Discussion in 'Animation' started by Laicasaane, Jun 6, 2018.

  1. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    26
    I'm using SimpleAnimation to make it be able for my logic code to control both legacy and mecanim animation clips. When the game starts, the SimpleAnimation will be created through the following procedure:
    1. Get all animation clips from either Animator or Animation component attached on the model.
    2. Instantiate these clips.
    3. If the clips were from an Animation component, set newClip.legacy = false.
    4. If the component is Animator, get out the Animator.avatar if there is any then instantiate it for later use.
    5. Call DestroyImmediate to destroy either the old Animator or Animation component.
    6. Add SimpleAnimation component to the model.
    7. Attach the avatar to the new Animator.
    8. Add all the animation clips to the SimpleAnimation component.
    9. Then my code would call SimpleAnimation.Play("clip name") or .Stop() at some specific time or conditions.
    In both Unity Editor and release builds, that procedure can create SimpleAnimation, add animation clips, get animation clip and state info correctly. In Unity Editor I could see the animation clips running. But they just don't run in release build (both legacy and mecanim)! There is no error, no warning, no message about what's going on. I don't know if that is because of me instantiate the clips at runtime or anything? Or I have misunderstood the usage of SimpleAnimation and use it wrongly?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,624
    yes this is probably the reason why it doesn't work, there is no need to instantiate those clip because they are asset that are referenced, have you try to just use the clips as is?

    Also it not possible to convert a legacy clip to a mecanim clip at runtime, that would only work in the editor
     
    Laicasaane likes this.
  3. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    26
    Thanks for this clarification!