Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity 2D Animation v2 - Preview Packages

Discussion in '2D Experimental Preview' started by rustum, Dec 17, 2018.

Thread Status:
Not open for further replies.
  1. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    Please pay attention to my comment: #308 -This is important :oops:

    The way that the designers of the 2D animation package decided to link information about the changes made in the editor with the layers of the PSB-file - seems to me wrong!

    -I can’t imagine such a technical pipeline of developing graphics for a game in which the artist is not able to delete the layer, rename or create a new one and transfer part of the already drawn (and even possibly already imported to Unity) to this new layer!
    -This is simply not possible with at least some serious editing of the picture!

    Layer names are what we can see, easily control and fix "if something went wrong" upon import!
    Layer identifiers - on the contrary - are not visible and cannot be edited!

    So why did you choose them to protect against "renaming layers" (which does not interfere, and even just necessary), when you had to do exactly the opposite?
    I do not understand :(
     
  2. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94

    I TRIED all of what you write, can't make IK to work, could you upload al little video PLEASE!
     
  3. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    2D Animation, PSD(B) Importer and Adobe Illustrator, tests and private investigations... :)

    In general, the question that I raised above: “link to the Name of the Layer or to ID” -is now the most important, the fundamental ability (for me) to use the 2D Animation package “in principle” depends on the answer to it.

    But I actually still have a lot of questions. :oops:
    And although they are all already "secondary" - still probably it is worth asking them... :D

    In general - everything is fine - the graphics exported from AI to the PSD-format are perfectly imported into the Unity, after renaming to the PSB-file. But there are many nuances.
    -If it’s not possible to flatten layers after, in Photoshop (Illustrator simply doesn’t have such functionality), then most likely (without applying a strict hierarchy of vector "fills" and "stroke" and excluding some vector tricks when drawing: transparency, mask etc) you will receive in your PSB file such a set of grouped paths.
    In this example, for the arms and legs - I did everything "as needed" for proper import, but the head and body are left "as is". Photoshop will show us clearly what happened inside the file. We get exactly the same layer structure when importing to Unity.
    As you can see, the names of the “correctly prepared” layers are exactly those that we gave them in the Illustrator, and they are represented by one sublayer, which is important (more on that - later),
    but with a head and a body - "we have a problem":
    2020-01-08_13-54-00.png 2020-01-08_14-11-53.png

    Yes, the importer has a “group layers” checkbox, but it won’t help us (at least in this version of the package), all he’ll do is hide the meshes in the hierarchy,
    2020-01-08_14-24-35.png
    but it won’t make it easier for us to work with graphics - here is a demonstration:
    2020-01-08_14-52-22.png
    As you can see, it is not possible for the "body" and "head" to assign the "category" and "label" correctly!
    "Converting group to category" gives the correct "category", but each individual layer/path gets its own "label"!
    But we need to make it look like what happened in the case of the "L_foot" - only in this case we can use SpriteResolver сomponent correctly. Otherwise, we get in it a set of individual elements of the body that can be selected only individually:
    2020-01-08_14-55-01.png

    But this - assign "Labels" correctly, cannot be done not only by automatically converting the group to a category
    (the result for the "convert layer to category" method will be even less satisfactory),
    but also assigning "labels" manually - only individual layers/paths have label fields!
    -But we need to assign a "label" to the whole "head1" and "body".

    Thus, we conclude that the “Use layers grouping” checkbox will not help us ...

    To be continued... :D
     
    Last edited: Jan 8, 2020
  4. LcarnesUB

    LcarnesUB

    Joined:
    Nov 4, 2019
    Posts:
    3
    Hello!

    I have been looking into different 2D animation packages to be used in Unity for upcoming and existing projects. I am trying to fully understand what features 2D Animation will have.

    Are any of the following, desired, features planned or implemented into 2D Animation?
    - Spline IK
    - Save selections
    - Controllers that can be zero'd-out
    - Partial or complete pose saving
    - Morph target / Blend Shape / Morphers
    - Transferring animation from one rig to another
    - Independent Position / Orientation / Scale constraints

    Thank you for your time, and forgive me if any of these features have already been discussed!
     
    EvOne likes this.
  5. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    Hi, the 'use layers grouping' is to generate a hierarchical GameObject structure that mimics the Photoshop file hierachy.
    In your use case, if the importer allows you to manually specify which Photoshop layer group to flatten, would that help?
     
    EvOne likes this.
  6. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    Some of the items you are mentioned are related to our future phase improvements which is related to control rigs and animating workflow. There are some items in your list that will be great if you can help elaborate on; and if you could give example use cases, which other tools that we can refer to that has this features

    - Save selections
    - Controllers that can be zero'd-out
    - Morph target / Blend Shape / Morphers
    - Independent Position / Orientation / Scale constraints

    As to 'Transferring animation from one rig to another', it is possible as long as the animation clip can find the correct target to apply the animation i.e. the GameObject hierarchy is the same.
     
  7. LcarnesUB

    LcarnesUB

    Joined:
    Nov 4, 2019
    Posts:
    3
    Thank you for your reply! Glad to hear some of these are being planned already!

    I would be happy to elaborate.

    - Save Selections -
    Photoshop selections, Puppet2D, 3D Studio Max have this functionality. It allows one the ability to save what is selected and then load that selection at a later point. For instance, one could select 16 fingers, save their selection, work on other things, then load that same selection later to move/rotate/scale them all at once.

    - Zero-out controls -
    Puppet2D has this feature, and is commonly built into 3D rigs in programs like 3D Studio Max. It is similar to a "Return to bind pose" function, but differs in that one can reset individual values. For example, let's say you wanted to move and rotate a foot a distance away from the bind pose, but then you wanted to keep all the values the same except the Y position and X rotation. With the ability to "zero-out" this controller, you could set Y position and X rotation to 0 and it should return just those transforms to the bind pose.

    - Morph Targets/Blend Shapes -
    Spine, 3DS Max, Maya, Puppet2D, AnyPortrait are some tools that have this functionality. This is the ability to take a mesh, edit the geometry's vertices into a different position and then blend between the different shapes. Usually this is controlled by a parameter or slider. This could be used for facial animation, or muscles bulging in conjunction with bones skinned to the mesh.

    - Position and Orient Constraints -
    This is something I haven't seen in 2D tools, but in every 3D tool I've heard of. Usually these are necessary to build an IK limb manually. They function very much like linking/parenting, however, instead of the child inheriting ALL of the transforms, it only inherits the positional, (or orientation for an orientation constraint) information. They can also be applied without affecting the hierarchy. When applying two parent constraints and adjusting the weight between them, one can make a scene with a ball laying on the ground, and then follow a hand when picked up. If both a position & orientation constraint are put on the object, the child will not inherit scale information. In this way a hand could have full squash and stretch from scaling, without scaling the ball it is holding.


    Hopefully these use cases and tool references help! If 2D Animation had all of these features, I think it would certainly outshine any Unity animation package that I've come across. I'm looking forward to its further development!
     
    Leo-Yaik likes this.
  8. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94

    I FOUND A BUG:
    that gives me:

    "Invoking TextureImporter.GetWidthAndHeight() failed: System.Reflection.TargetException: Non-static method requires a target.
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004c] in <437ba245d8404784b9fbab9b439ac908>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0
    at TPImporter.TexturePackerImporter.GetOrigImageSize (UnityEngine.Texture2D texture, UnityEditor.TextureImporter importer, System.Int32& width, System.Int32& height) [0x00073] in <cfda03865c6248fa96ca96afc319bd04>:0
    UnityEngine.Debug:LogError(Object)
    TPImporter.TexturePackerImporter:GetOrigImageSize(Texture2D, TextureImporter, Int32&, Int32&)
    TPImporter.TexturePackerImporter:OnPostprocessTexture(Texture2D)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    HOW TO TRIGGER IT:
    1)-include IKs and solver in your gameobject, thus, make an IK solver on a leg, on arms and so on.
    2)-Open the PSB file and change the layer orders. plus take a layer out of group folder in Photoshop.
    3) when you come back into unity it gives this error and it cannot update the prafab into the scene.

    How to solve it?

    If you want to make that the PSB layers reflect the same object hierarchy, you should make it resilent to any changes tat are made on the objects, like adding IKs and so on..
     
    EvOne likes this.
  9. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    I'm sorry to be late with the reply... :oops: - I'm not lost. -just I'm trying to explain the complexity of the situation, as I see it.
    Explain with examples as briefly as possible and at the same time not missing important details.
    Unfortunately, the my "language barrier" does not help me with this...

    As for Your question and the possible solution proposed by You, I did not quite understand how this will be implemented. -From the description (as I understand it) this can solve the problem, but as always, everything depends on the implementation details...

    Wait a minute -I will try to show in more detail with screenshots what exactly seems to me not quite true in this import process...

    wait... Wa-a-aait! -3.1.0? WOW!!! :)))))))))))))))))))))))))))))

    -while I "sat" in Illustrator, for the last few days, completing my script (so that there was something to show) - an animation package update was released! :D

    [3.1.0]
    Changed
    • Changed how Samples are imported into the user's project
    • Updated Third Party Notices file
    Fixed
    • Fix Animation Samples crashes when installing on certain machines (case 1185787) - Yes! It' my case! :rolleyes:
    • Fix visual glitch when using SpriteSwap with Multi-threaded rendering (case 1203380)
    • Fix bone name misaligned under Weight Slider Inspector when a name contains more than 26 letters (case 1200873)
    • Fix bones not chained correctly when splitting bone in certain cases
    • Fix 'Label' and 'Sprite' name overlaps with its input field when preset of "Sprite Library Asset" is created (case 1201061)
    • Fix bone names can be empty (case 1200861)
    • Fix bone gets created even though clicked on Visibility Panel (case 1200857)
    • Fix NullReferenceException when using shortcut 'Shift+1' in certain cases (case 1200849)
    Added
    • Expose SpriteSkin component to be accessible from scripts. - !!!!! :)

    Big BIG BIG Thanks!!! :D
    I'm running to try the improvements ...
     
    Leo-Yaik likes this.
  10. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94
    My PSB file shows this structure inside UNITY in the project view:
    -Character
    ---->ARM
    ---->LEG
    ---->TORSO
    BUT IS NOT ALIGNED TO WHAT IS PHOTOSHOP! ( where is instead LEG,ARM,TORSO)
    if I open it in photoshop it shows a different order.

    It seems the order is respected in Unity only in Sprite sorting Layers but NOT in the object's structure.

    How can I force UNITY to have the object structure like the PSB file in photoshop?
     
  11. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    Hi!

    Alt-skin_Orc_with_One-Problem-Layer.PSD -Here is a simple example, in attachement.

    -If for this file it would be possible to group the nested layers for the “Head”, so that the two sprite variants would change in the same way as done for "R_Hand" -this would be a solution! :)

    SkinEditor_chBoxGroupLayers_On.png chBoxGroupLayers_OFF.png 2020-01-25_21-48-37.png

    The grouping of layers, now, does not solve the problem, and not intended for this, as you explained,
    but -in addition, Grouping by itself -causes an additional undesirable (from my point of view) effect - the appearance of an additional child object: "R_Hand_1" on which the SpriteResolver is located - which may cause problems when refactoring the animation.
    - simple "R_Hand" with the SpriteResolver on it - would be much more convenient result.
    2020-01-25_21-50-39.png
     

    Attached Files:

    Last edited: Jan 25, 2020
  12. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    94
    could you add CLOTHES or WIND effect support? to deform clothes, scarfes, flags and so on with the wind?
     
  13. SNTdev

    SNTdev

    Joined:
    Mar 27, 2017
    Posts:
    8
    @Leo-Yaik

    Hi, do you know if Is there any way to use the 2D animation package in the UI? For characters at visual novel style game. The 2D animation package uses the "Sprite renderer" component and that doesn't show up on UI, only image component does

    The workaround I'm using is 2 cameras, one for the 3D scenario, and one for the animated character images, marked as "Don't clear"

    "Universal Render Pipeline" removes this workaround, it's not possible to combine 2 cameras anymore

    Thanks
     
    Last edited: Jan 27, 2020
  14. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    Anybody home? May be its wrong Place for questions? Here is many other trheads about PSD Importer, 2D Animation package...
    Well, I hope someone can still hear me ...

    -Are there any plans to expand the functionality of the PSD Importer to work with Adobe Illustrator?
    As an artist drawing in a vector and not using Photoshop in my work, it’s very important to know, for me

    If any steps in this direction are planned, - I have collected useful information
    regarding the link: "Illustrator-> export as psd -> PSD Importer", which, I hope, can be useful to you!

    About that "Problem", about which I have been writing for a long time in this thread, I found its causes. :(
    The problem is not quite where I suspected.
    But now I know what the "root of evil" is :mad: Unfortunately, I can hardly do something about it myself ... :(

    Here is a set of factors that caused the Problem:

    -My choice of a drawing program different from the one for which they developed the PSD Importer.

    - A way to bind information to layers ID, which works great with Photoshop.

    -Well, the strange Adobe policy regarding these IDs for layers - apparently, they just don’t exist in Adobe Illustrator,
    And they are assigned only at the time of export to Photoshop format, since they are used there.
    and ID are assigned, just in accordance with the order of the layers. OMG...

    And that's why any change in the hierarchy of layers in Illustrator - rearrangement, insertion, deletion - any action with layers - immediately breaks the whole binding,
    since the IDs are exceeded when exporting again, completely "from scratch", in accordance with the new order!..

    And this catastrophe, when the information about the rigging and the skinning is distorted or disappears after each editing when re-exporting "Ai -> Ps",
    -happens only with me. Since in Photoshop - everything is ok.

    I suspect - no one could understand - what he was trying to shout about in his incomprehensible "broken" English through Google translate... :oops:
    -Since the problem is not visible until someone tries to work with the Adobe Illustrator and PSD Importer ...

    ---
    Here are screenshots of my research. I tried to show everything as briefly and clearly as possible.

    How IDs work in Photoshop - what can then be seen after importing into Unity for rearranged layers:
    2020-01-27_00-29-24.png 2020-01-27_00-32-40.png

    And this is how it works if you do the same in Illustrator, and then export to .psd:
    2020-01-27_00-53-31.png 2020-01-27_00-57-34.png
     
    Last edited: Jan 28, 2020
  15. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    @EvOne we are looking for a more elegant solution for this; this might take a bit of time.
    If you already have Photoshop on your machine, one possible way is to use SmartObject in Photoshop

    1. Have Illustrator export out your layers as images.
    2. Reconstruct it in Photoshop from those images with the images imported as SmartObject in Photoshop.

    I know this is not ideal for the moment; rest assure we are tackling the issue.
     
    Betzalel and EvOne like this.
  16. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    Thanks for the feedback. We will add this into our backlog.

    As for now, you can possibly add 2D Physics components to the bone GameObjects to simulate those behaviour.

    If you look at the Lost Crypt 2D demo, the pony tail was controlled via physics.
     
  17. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    I assume this is because you want the 2D characters to be anchored to a specific place regardless of the screen ratio/resolution.

    I believe this can be done by having the Canvas RenderMode set to Screen Space.
    1. Add a GameObject in the Canvas (this should give you a RectTransform).
    2. Set the GameObject's RectTransform anchor and place the GameObject where you will want it to be
    2.1 You can add an Image component to this GameObject and try resizing the Game View to verify the Image stay in place
    3. Add the SpriteRenderers as child of this GameObject and position it where you want it.
     
  18. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    111
    I'm not sure, but ...
    Are you talking about the situation with layer identifiers in Illustrator? and not about post number #411?
    I’m a little confused, it’s possible even in the case of “orc head” smart objects could also help,
    so I'm not sure what my post is about ... :oops:

    But, if that’s all said about the Layers and ID... Wow! -So this is not a dead end, as I have already decided!
    -Are you working on importing from Illustrator? and I have hope again? Wow! :))))))))))))))))))))))))))))))

    As for smart objects, I need to think... can I "fit" all this into my workflow... not sure...

    -I didn’t show it before, but I tried, as far as possible, to automate my work in Illustrator, -work with skins, parts of the character and variations of these parts.
    -A minimum of manual actions for typing names. All the names are described in the code (in a config or text file, in the future, maybe) and we just have to select them from the "matrix" of checkboxes corresponding to the desired rig...
    And the format of the layer name and hierarchy of groups and layers is adjusted to the PSD Importer :)
    so that after selecting the action "convert group in the category" - we get the right set of sprites for the resolver.
    I guess I just need to show the process ... :)

    Here is a link to the video in which I tried to briefly show the main features of my script:
    -Switching "skins", variations of objects: hands, feet, head. Just select from dropdown lists, without clicking on many-many smallest icons of Illustrator's Palette of Layers!
    -Create a new object from the selected. The name of the layer contains the name of the body part, the "skin" and the variation of the body part
    -Creating a file prepared for export, and export to psd.

    https://drive.google.com/file/d/12XHkjbrfiGEIhD8DOaIuo10eKF48JqGQ/view?usp=sharing

    As you can see, there is already much that will make it more convenient to work with many drawings of various characters. Although of course the script is still very "raw" and not very stable, but nonetheless...

    But for working in Photoshop with smart objects ... -I don’t have a similar solution ...
    I'm not even sure that I can write scripts for Photoshop... :D
    although this is the same ExtendScript as in Illustrator...
    But, this is Adobe... :rolleyes: everything is complicated with them ...

    P.S. The link to the video posted to Googledrive could not be inserted as "media"... :(
    do I need to transfer it to YouTube?

    there link is just a video. -here are a couple of frames from it:
    AI_Script_01.mp4_snapshot_00.40_[2020.01.29_04.04.52].jpg AI_Script_01.mp4_snapshot_01.48_[2020.01.29_04.03.39].jpg
     
    Last edited: Jan 29, 2020
    HuldaGnodima likes this.
  19. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    29
    Hi I have a couple of questions about performance :)

    Performance of Unity's 2DAnimation:
    I was wondering if you know how 2DAnimation compares to Anima2D performance-wise?

    I'm testing them both, and with Anima2D when I copy several sprites animated with Anima2D into the scene the fps remains more or less the same. Super nice performance. If I do the same with sprites animated with Unity's 2DAnimation the fps/computation-times take big hits however.

    Made a home-cooked performance test (Anima2D seems to beat 2DAnimation)?:
    I did a performance-test with small sprites. I've attached a video with it below. When I turn on 36 animated objects (with 6 vertices & 3 bones each) with Anima2D vs 2DAnimation the CPU rendering-time is ~ 11 ms for Anima2D and ~13 ms for 2DAnimation.


    (See 00:29 for 36 animated objects Anima2D and 01:23 for 36 animated objects with Unity's 2DAnimation)

    There's a difference of 2 ms for just 36 sprites. Do you know if Anima2D has better performance than Unity's 2DAnimation, it seems so? Or do you know how they compare?

    Here's an image via the profile to show the difference in how much cpu Anima2D takes and 2Danimation takes for the same task as well, if it helps any:



    Will 2DAnimation's performance improve soon?
    And if 2DAnimation isn't as good performance-wise, will that change in the near future? I plan on having NPCs and trying to use 2DAnimation with 3 characters bogged my computation time to 30 ms (while Anima2D kept it at 11 ms). That means that if the performance doesn't improve for Unity's 2DAnimation it isn't viable option for me unfortunately :( although I very much love the workflow!

    I really appreciate any input, thank you all for your advice :)
     

    Attached Files:

    Last edited: Jan 30, 2020
  20. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    294
    @HuldaGnodima Hi, which animation package is this benched marked on and is the experimental 'performance mode' enabled?

    Depending on which package version you are on, the performance mode can be enable by either installing the Burst or the Collection packages
     
  21. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    29
    Hi Leo!

    Thanks for your reply. The version I'm using is 3.1.0.
    I'd love to try the performance mode, do I download the Burst or Collection for v 3.1.0? :)

    Am I correct in understanding that the 2DAnimation will be more efficient in the future? If so do you know the approximate time-frame, and will it be able to compete with the performance of Anima2D?
    The reason I'm asking is because I'll (possibly) have 5~15 NPC on the screen at once, and currently 2DAnimation is too performance-heavy to use for this, while Anima2D does the task without affecting fps much.

    2DAnimation is such a lovely and easy to use tool though, and I would prefer using it as it's also native to Unity now. So If it will be efficient enough in the future to handle this well I'd love to know, then I will fix my animations in 2DAnimation and wait for the efficiency to come :)
     
    LeleUnity and rustum like this.
  22. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    94
    HuldaGnodima likes this.
Thread Status:
Not open for further replies.
unityunity