Search Unity

Create animation clips from script

Discussion in 'Animation' started by mrm83, Dec 16, 2020.

  1. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    Is it possible to create animation clips from script instead of using the animation editor?

    We have a bunch of 2d sprite frames thats used to create an animation and would like to create the animation by script.

    ie: frame 1, use frame1.png
    frame 2, use frame2.png
    frame 3, use frame3.png
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    It is, but only in the Unity Editor, not at runtime. I made a tool to quickly Generate Sprite Animations based on their names.

    I found the basic code for it somewhere in Unity's Editor source code, but it was quite a while ago now and I can't remember where exactly it was.
     
  3. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    That won't work for me. I need to assign a sprite to a specific sprite renderer.

    The tool you posted is just like drag and drop which creates an animation on the same object with the animator.
    My animator is not on the same object so this won't work.
     
  4. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    The remap sprite animation tool may just work very well. Didn't think of remapping the sprites to another set of sprites! Thanks!