Search Unity

Resolved Generate AnimClip asset from the Context Asset Menu

Discussion in 'Animation' started by pioj, Mar 17, 2023.

  1. pioj

    pioj

    Joined:
    Nov 5, 2012
    Posts:
    34
    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! :D
     

    Attached Files:

  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    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.
     
  3. pioj

    pioj

    Joined:
    Nov 5, 2012
    Posts:
    34
    I'm speechless. When/where was this featured and shown in the manual????

    Firrst time I see this, really..
     
  4. pioj

    pioj

    Joined:
    Nov 5, 2012
    Posts:
    34
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    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.
     
    pioj likes this.