Search Unity

Official 2D Animation is out of preview for 2019.3

Discussion in '2D' started by rustum, Jan 30, 2020.

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

    cyanryanlion

    Joined:
    Feb 17, 2020
    Posts:
    25
    Hi, is the performance improvement intended to work on WebGL? I'm finding it's made a huge improvement on Windows standalone as well as iOS, but WebGL it's almost unusable (60fps with no spriteskins and 8fps with 6 sprite skins, 3 bones and 79 verts each, profiling shows loads of time spent inside SpriteSkinManagerInternal.LateUpdate).

    Unity 2020.1.0b5
    2D Animation 4.2.2
    Burst 1.3.0-preview.9
    Collections 0.7.1-preview.3

    EDIT: Turns out burst isn't supported in WebGL (yet), and so the optimisation (which requires collections and burst packages) can't be used, making sprite skin just way too slow to use :(
     

    Attached Files:

    Last edited: Apr 29, 2020
  2. thehen2

    thehen2

    Joined:
    Apr 1, 2014
    Posts:
    54
    I'd love to know how to do this. At the moment this is unusable for my purposes.

    Assuming I can construct the character in the scene, does that mean I could use different sprite materials on different parts of the character?
     
    Last edited: Apr 18, 2020
    SystemId likes this.
  3. SystemId

    SystemId

    Joined:
    Aug 5, 2016
    Posts:
    11
    I've been wondering this too
    .. I am kinda guessing he's talking about the rigged character after using the PSB process
    Taking individual sprites from another sprite sheet and in each "part" and manually replacing each sprite from each game object parts. Realigning them up to remake the character.

    So far the current process is only really usable if all your art is done completely without needing updates. Maybe also useful for testing somethings out, but it's not good for actual production use.

    : ( I'm going to put using this on hold, until a better process is ready.
     
  4. Azzara777

    Azzara777

    Joined:
    Mar 10, 2013
    Posts:
    10
    I wanted to implement squish-and-stretch by creating two bones on the same limb part (for example upper arm).
    The parent and the child bones both had exactly the same position and rotation. I was planning to use the child bone only for stretching in order to avoid non-uniform scaling issues in the hierarchy. And the parent bone for the usual translations and rotations.

    However, now I can't select the manipulators of the parent bone. Ever. It always selects the child bone.

    I tried changing the bone depths. Didn't work.
    Tried disabling the visibility of the child bone. Didn't work.
    Tried clicking on it multiple times to select the one behind. Didn't work.
    Tried selecting it in the hierarchy first and then moving the bone manipulator in the viewport. Didn't work.
    Played around with the suspicious eye and finger icons in the hierarchy. Didn't work.
    Tried hiding the child bone game objects in the hierarchy using hide flags. Didn't work.
     
    Last edited: Apr 19, 2020
  5. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Yes, you can use different Sprite materials for different part.

    You can install the samples that comes with the 2D Animation package to check out how it is possible to rig PNG files
     
    thehen2 likes this.
  6. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Can you share your setup?
     
  7. Azzara777

    Azzara777

    Joined:
    Mar 10, 2013
    Posts:
    10
    Sure. There is a project with two sprites which demonstrates the problem (made in Unity 2019.3.9f1).
    The two most important bones Lower and Upper are practically unselectable in the viewport.
     

    Attached Files:

  8. Dastashka

    Dastashka

    Joined:
    Oct 11, 2018
    Posts:
    3
    Hello, i have a problem with changing sprite in Sprite Render component. For example i have a picture A with bones and animations already, but i've added color correction for example on my sprite and now i want to change my Sprite A to sprite B and kjeep bones and animation working.

    But when i change sprite in Sprite Render component i got my all bones reset and i can't apply any of them. Is there any way to just change sprite and keep animations?
     
  9. Dastashka

    Dastashka

    Joined:
    Oct 11, 2018
    Posts:
    3

    For those who has the same problem:
    https://docs.unity3d.com/Packages/com.unity.2d.animation@2.2/manual/SpriteSwapIntro.html
     
    Leo-Yaik likes this.
  10. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    To swap in a Sprite that is rigged, make sure both Sprite has the same number of bones. You can use the Copy/Paste function in the Skinning Module to copy it over.
     
  11. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Thanks for sharing. We take a look at working on the selections
     
  12. Game-Whiz

    Game-Whiz

    Joined:
    Nov 10, 2011
    Posts:
    122
    Hi,

    I'd like to be able to switch the resolution of my sprites at runtime. I tried using sprite atlases but the results weren't good at all (everything got really distorted). Is there a way to have different resolution assets? If not, is it planned?

    Thanks,
    Alex
     
  13. vgf555

    vgf555

    Joined:
    Mar 21, 2019
    Posts:
    6
    Hello, I had an error copying bones from one file to another.
    Target has a different number of Sprites (185) compared to copied source (9) for Mesh copy.
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
    How can I copy bones on a different number of layers?
    I'm very sorry. My English is very poor.
     
  14. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Since the number of Sprites is different between your files, you will need to select the individual Sprite you want to copy and paste it to the Sprite that you want
     
  15. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    97

    Dear Leo I have download the project but:
    IT's on MAC OS, I am on windows instead.
    I have imported and converted the project but it is empty, there is only an empty sample Scene with a camera.
    Could you please upload something that can work on my side?
    Thank you very much!
     
  16. thehen2

    thehen2

    Joined:
    Apr 1, 2014
    Posts:
    54
    Has anyone attempted to do 8-directional tilted top-down movement using the 2D Animation Package?
    Would you just use sprite libraries and the sprite resolver to swap body part sprites based on direction - maybe a PSB for each direction?
     
  17. -hiTo-

    -hiTo-

    Joined:
    Jul 22, 2013
    Posts:
    9
    I would go one of two ways, depending on your game:
    Either A) if you have armor that may be swapped out, or want to show damage to limbs or body parts and so on, create a library for each direction, and simply swap the library out when you change direction. This way, you can use spriteresolver categories and labels to do your armor/other sprite swapping not related to direction.
    Or B) if you only have the different directions to swap with, use the spriteresolver categories and labels to swap directions.
    You could technically do A and use categories for directions, and labels for swapping between sprite states, but libraries don't really play well with the unity ui when they're massive collections (they lag like crazy, someone should probably make a bug report about it tbh).
     
  18. jeanpoolay

    jeanpoolay

    Joined:
    Mar 28, 2017
    Posts:
    8
    Skel8.jpg
    Hello Unity family,
    This is my issue, Say Hello to my Skeleton crash tester, The Skeleton default pose in my PSB file is at the left of the screen.

    The GOAL is to duplicate the atlas generated by Unity ( at the right of the screen) for a NormalMap secondary texture .

    But I cannot Duplicate/Isolate or whatever ....I'm lost, anyone can help me ?

    And thanks for all the talentuous team
     
  19. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Here's a sample script that allows you to extract out the atlas generated by PSDImporter
    You will need to enable the Image Conversion module from PackageManager under the Packages->Built-in

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.IO;
    4. using UnityEditor;
    5. using UnityEngine;
    6. using UnityEngine.Experimental.Rendering;
    7. using UnityEditor.U2D.PSD;
    8.  
    9. public class ExtractPSDImporterAtlas
    10. {
    11.     [MenuItem("Assets/Extract PSDImporter Atlas")]
    12.     static void ExportMosaicTexture(MenuCommand context)
    13.     {
    14.         var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(Selection.activeObject)) as PSDImporter;
    15.         if (importer == null)
    16.             return;
    17.         var assetPath = importer.assetPath;
    18.         var texture2D = AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath);
    19.         if (texture2D == null)
    20.             return;
    21.         if (!texture2D.isReadable)
    22.             texture2D = CreateTemporaryDuplicate(texture2D, texture2D.width, texture2D.height);
    23.         var pixelData = texture2D.GetPixels();
    24.         texture2D = new Texture2D(texture2D.width, texture2D.height);
    25.         texture2D.SetPixels(pixelData);
    26.         texture2D.Apply();
    27.         byte[] bytes = ImageConversion.EncodeToPNG(texture2D);
    28.         var fileName = Path.GetFileNameWithoutExtension(assetPath);
    29.         var filePath = Path.GetDirectoryName(assetPath);
    30.         var savePath = Path.Combine(filePath, fileName + ".png");
    31.         File.WriteAllBytes(savePath, bytes);
    32.         AssetDatabase.Refresh();
    33.     }  
    34.    
    35.     public static Texture2D CreateTemporaryDuplicate(
    36.         Texture2D original,
    37.         int width,
    38.         int height)
    39.     {
    40.         if (!ShaderUtil.hardwareSupportsRectRenderTexture || !(bool) ((UnityEngine.Object) original))
    41.             return (Texture2D) null;
    42.         RenderTexture active = RenderTexture.active;
    43.         RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, SystemInfo.GetGraphicsFormat(DefaultFormat.LDR));
    44.         Graphics.Blit((Texture) original, temporary);
    45.         RenderTexture.active = temporary;
    46.         bool flag = width >= SystemInfo.maxTextureSize || height >= SystemInfo.maxTextureSize;
    47.         Texture2D texture2D = new Texture2D(width, height, TextureFormat.RGBA32, original.mipmapCount > 1 | flag);
    48.         texture2D.ReadPixels(new Rect(0.0f, 0.0f, (float) width, (float) height), 0, 0);
    49.         texture2D.Apply();
    50.         RenderTexture.ReleaseTemporary(temporary);
    51.         texture2D.alphaIsTransparency = original.alphaIsTransparency;
    52.         return texture2D;
    53.     }
    54. }
    55.  
     
    jeanpoolay and EvOne like this.
  20. dcyric

    dcyric

    Joined:
    Feb 2, 2015
    Posts:
    13
    I had an issue when swapping sprites by code when the sprites are packed into Atlas (both new and legacy).
    Using the UnityEngine.U2D lib, we have a character that has Sprite Skins, Bones and everything, import by PSB etc. I am swapping Sprite of SpriteRenderers by code (below is the code to give an idea). And this is during runtime.

    upload_2020-5-7_16-10-3.png

    If I am referencing the sprite via a GameObject monobehaviour script, without packing it into an Atlas, everything is fine. The deformation works nicely.

    Once I packed the sprite into an Atlas, this happens after the swap:

    InvalidOperationException: custom sprite vertex data size must match sprite asset's vertex data size 720 396
    UnityEngine.U2D.SpriteRendererDataAccessExtensions.SetDeformableBuffer (UnityEngine.SpriteRenderer spriteRenderer, Unity.Collections.NativeArray`1[T] src) (at <1245d947a91b4a14b7c7e2c7335512b2>:0)
    UnityEngine.U2D.Common.InternalEngineBridge.SetDeformableBuffer (UnityEngine.SpriteRenderer spriteRenderer, Unity.Collections.NativeArray`1[T] src) (at Library/PackageCache/com.unity.2d.common@2.0.2/Runtime/InternalBridge/InternalEngineBridge.cs:15)
    UnityEngine.U2D.Animation.SpriteSkin.LateUpdate () (at Library/PackageCache/com.unity.2d.animation@3.2.2/Runtime/SpriteSkin.cs:319)

    Is this operation something that conflicts with Atlases? (the swap in parts are standalone pngs, not part of PSBs)
     

    Attached Files:

  21. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    110
    Hiya!

    I was wondering if there's support for using Avatar Masks with 2DAnimation?
    For example to be able to mix a "holding item in air"-animation (that only effects the arms) and a "running"-animation (that affects the lower body) seamlessly? Below is an image of me attempting to use Avatar masks:


    I'm giving it a try right now in Unity, and I'm unable to find a way to make a custom skeleton out of 2DAnimation-bones, to use in the Avatar Mask.
    To use the avatar-mask I must somehow connect the 2Danimation bones with the Avatar Mask to be able to select bones that should be affected (like only the arms) when the character is holding something. With 3D-bones this seems to be done for eg. with skeletons like in the image below:


    I cannot find anything online on how to make 2Danimation skeletons for avatar masks.

    My Questions:
    1.)
    Is there a way for me to use Avatar Masks using the 2DAnimation package as described above?
    2.) If not, are there plans to add support for this?
    3.) Do you know of another way I can achieve the affect described above, if not possible with Avatar Masks?

    Thanks in advance!
     
    LeleUnity and EvOne like this.
  22. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    97
    I just know that you can override a layer animation for just the arms, setting the weight to 1. Check "layers in animation" this is how I do.
     
    HuldaGnodima likes this.
  23. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    110
    Thank you for your suggestion, it made me investigate Animation-Layers further.

    Prior to asking the question above I was trying to use the Animator-Layers as well. I'd made a temporary "holding item" animation that affected all bones, and when I dialed up the weight the whole body was effected (when I only wanted the arms to be affected).
    But following your advice I remade the "holding item" animation to only alter arm-bones, and when I slide the weight to 1 now it works!

    Thanks so much! :)
    This is exactly what I was looking for.
     
    LeleUnity likes this.
  24. thammin

    thammin

    Joined:
    May 7, 2018
    Posts:
    1

    Library/PackageCache/com.unity.2d.animation@3.2.1/Runtime/TransformAccessJob.cs(196,46): warning CS0618: 'NativeHashMap<int, TransformAccessJob.TransformData>.Length' is obsolete: 'Use Count() instead. (RemovedAfter 2020-05-12). (UnityUpgradable) -> Count()'


    Hi, we found that TransformAccessJob.cs was using obsolete API which invoke ScriptUpdater every build in our pipeline. Hope this can be fix in the upcoming release.
     
  25. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    @Leo-Yaik Is there anyway to get these animations working with ScreenSpace UI?

    I can't use worldspace with the 2D URP as is.
     
    Last edited: May 16, 2020
  26. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Since it uses SpriteRenderer, it won't be possible at the moment. Let us check it out and get back.
     
  27. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Can you tell us why you weren't able to do so?
     
  28. VektaCo

    VektaCo

    Joined:
    Sep 30, 2019
    Posts:
    31
    Currently no Camera stacking in 2D URP, so Post Process effects get on my UI :(
    Also using Additive scenes and using 3rd party plugins that do not play nice with Worldspace UI

    Appreciate the work you've done so far on this, it's pretty slick.
    I've used Spine2d on my previous projects, but have made the switch! :)
     
    Last edited: May 19, 2020
  29. Volandpro

    Volandpro

    Joined:
    Mar 7, 2014
    Posts:
    7
    Hello!
    Is it possible to create bones in Sprite Skin component with code? Thank you!
     
  30. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    In runtime or editor time?
     
  31. Volandpro

    Volandpro

    Joined:
    Mar 7, 2014
    Posts:
    7
    In runtime
     
  32. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    Sorry, noob question here. I have read through docs but I likely missed this or forgot it...

    I am curious, I want to snap my rig to a grid. I have a mechanical spaceship that I want to precisely align the bones to elements on the ship. its pixel art, so I have an idea where I want things, but I can get it precisely there. Is there a way to snap, or enter information precisely? . I also want the rig to be symmetrical but haven't found a way to copy a portion of the rig. Same thing for while animating, I want to precisely pose the rig?

    Tips? Did I miss this in the manual somewhere?

    I have no problems with organic objects and rigging non pixel art, but for mechanical things and pixel art, I want, no, I NEED precision. I literally can't sleep at night if I know my models geometry is aligned when it is supposed to be.
     
  33. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    One more thing. When I am setting up a rig, I import a photoshop file. Everything is great, except two things:

    First I want to mirror the right wing and not have to include a left wing as a layer. Is this possible? Essentially, I have a symmetrical model and don't see the point in duplicating data, but can't figure out a good way to do this.

    *edit* -Solved second problem. See below.

    Secondly, this is a fantasy space ship, and the wings are unattached and are just floating there. However, for the sake of animation, the rig is all attached and there are several bones in space that don't have any weights on the texture. They simply exist for ease of animation. However, when I drop the model in the scene and try to animate, the bones that have no weight on the mesh no longer exist as tools to interact with. The transform is there in the prfab, but the bone isn't displayed in the editor and I can't edit it the same as the others, if this makes sense. Basically, the wings function as bird wings, but with much of the wing "invisible". I need the bones in the invisible part to make a good animation.

    *edit* -Solution.

    I had to add to add the bones with no weight as an influence on a sprite. Once they were "influencing" a sprite, they are properly set up when you drag the prefab to the editor. But they have no weight on the sprite.
     
  34. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    guys ,, iwish i can animate the swap sprite
     
  35. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    This would be very nice.
     
  36. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
  37. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
  38. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    ah damn ,,i forgot to install the ik ,damn
     
  39. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    i appreciate this so much ,this is what i looking for ,,
    Guo2CtFcja.png

    but the eye liner should not completely dissappear

    JcE8cXe9vH.png

    I want the eye liner to have a border
    can some one teach me how to set it?
     
  40. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    sometimes ,when i edit the psb file on photoshop then save it ,it wont update automaticaly ,damn cry
     
  41. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    this error appear when i edit the psb file then save it
     

    Attached Files:

  42. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    We are putting in a fix for this.
     
  43. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    A possible way is to have the eye liner as a different layer. Or use the custom mesh tool to create edges around the eye liner so that it can have a better fine control in deformation
     
  44. melkumew

    melkumew

    Joined:
    Jun 15, 2020
    Posts:
    1
    Wow, looks great!
     
  45. Betzalel

    Betzalel

    Joined:
    Dec 3, 2017
    Posts:
    22
    Hi @Leo-Yaik !

    I'm trying to override iks (using Solver2d) that are used in a mechanim animation but stumped on how to achieve this.
    To be more specific:
    I have a running character animation. I want to equip a gun to the character. I can't get the target IKs for the hands to follow the gun because the animation itself is moving them in the clip as well. If I remove the IK targets from the animation clip itself, then everything works, but obviously I lose my arm animation. Can you help me or point me in the right direction in order to achieve this so I get the best of both worlds?
     
  46. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92

    please update the example
     
  47. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    Can you please add confirmation of destructive action to the 'Revert' button on the Skinning Editor? The amount of times I've accidently clicked on it and lost a large amount of work is more than it should be.


    The UX for such an important tool really needs to be improved.
     
    EvOne likes this.
  48. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72

    Snap?
     
  49. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    Mirror?
     
  50. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372
    Is there a way to simply assign a sprite with 100% weight to a specific bone? Right now I select the sprite, the bone, assign the bone to the sprite, and then go in with the weight brush. Would be nice if I could just skip the last step.
     
    EvOne likes this.
Thread Status:
Not open for further replies.