Generate AnimClip asset from the Context Asset Menu

Hi, I didn’t found any relevant documentation for this at the forums, so I think I should post it here…

(sorry for the inconvenience if it’s already stated somewhere else)

Some people may argue about how the Animation Window is not the best tool when working with classic 2D Sprites frame-based animations, spritesheets, etc.

We have a few external tools for importing animations directly from ASEsprite and other related software, but I think it would be great addition for Unity to have a way of creating animation clips from a selection of sprite frames.

That should be more than enough for quick prototyping or to complement other tools we have in mind, like FSM generators…

I’ve started my take on this, but I’m stuck figuring out how AnimationCurves are related to Keyframes for sprite swap animations:

Please feel free to share your opinion about this.

Thanks! :smile:

100000001218704--1121384--clear.png

You can already do that by dragging and dropping sprites into the Hierarchy window.

If you want to do it with a menu function, you should ask for the file path first so you can return before doing anything else if they cancel it.

And filepath.Equals(null) will literally never work because if it’s null you can’t call methods on it. Either use filepath == null or string.IsNullOrEmpty(filePath). Similar for the frames.

I’m speechless. When/where was this featured and shown in the manual???

Firrst time I see this, really…

Done! I had to go back to a remote post in 2015 in order to finish the script…

Download: https://gist.github.com/Evolis3d/5ca204818f02c77a1898c10769e08cb3

I added it to my .UnityPackage repository too. Feel free to ask me for it, if you don’t know how to use the above code.

frames.Equals(null) and filepath.Equals(null) are still not going to work as intended. It can never return false because if they’re null, calling a method on them is going to throw a NullReferenceException. That would obviously cancel the rest of the method, but in that case you might as well just not check and let it throw whatever other exception it’s going to throw.

1 Like