Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

Various 2D packages feedback

Discussion in '2D Experimental Preview' started by GamerXP, Dec 23, 2020.

  1. GamerXP


    Mar 22, 2014
    Hi. I've being using 2D packages for a while, and I encountered a lot of issues. Some of them can be considered bugs, some are just missing functionality. I've fixed most of them by editing source package, and want to suggest doing something similar in original packages.

    2D Animation:
    • SpriteLibraries and SpriteResolver don't work with blending at all. In normal transitions it may be not that bad, but in blend trees they stop working altogether unless you perfectly align with one of blend poses. To fix that, I had to rewrite it so SpriteResolver uses Material serialized fields instead of float onces - object references are only types of values that can be swapped properly without generating any in-between values, and Materials are only animatable UnityEngine.Object that got field that you can assign directly.
    I generate materials for each sprite in SpriteLibraryAsset and store hash values there, then use them for serialization.
    Code (CSharp):
    1. mat.mainTextureScale = * SpriteResolver.ConvertIntToFloat(SpriteLibraryAsset.GetStringHash(spriteName));
    I tried reporting inability to animate ScriptableObject fields, but support said it's "by design". That's, pretty much, why I'm using timelines for everything now - I can't animate most extra things with normal animations.​
    • SpriteSkin. There are multiple things:
      • Flip values of SpriteRenderer doesn't work at all with SpriteSkin. This is why I added TransformRoot field that lets you select which transform will be used as base for flipping. I modified SpriteSkinUtility.Deform a bit to make it work.
      • Scale, Offset and Flip options. Those are not must-have, but they are good to have when you want to change only current sprite's values without affecting children. This can't be done easily with transforms, so having such values is a good thing. Only thing is - "Flip" should be as int value instead of bool, since bool blends in the wrong way - this is why I added it even though SpriteRenderer got own flip value. Really, original Flip values of SpriteRenderer are totally broken when blending.
    2D IK:

    Again, flip value doesn't blend well. But in this case, I made flip values as float in range from -1 to 1. At -1 and 1 it behaves the same way as before, but at 0 it looks like bone is bending toward camera (basically, it only decreases in length and is not bent at all). This creates perfect blending between 2 values and also gives more options for limb animations.

    PSD Importer:

    Right now, there is no way to get sprite positions relative to their original positions in PSD other than generating character rig and using it as reference. Instead, I added "Use Global Pivot" flag for importing. When active, it makes all sprite's pivots to be at position relative to PSD files instead of relative to sprite. That means that if you then place all sprites from PSD at zero position in scene - they will be at same positions as they were in PSD.
    It can be also useful to have some sort of API to access those relative positions data of PSD files somehow.

    2D Lights:

    It will be nice to have some settings for generating textures used by lights. For example, decreasing their size and making them have sharp transitions that looks good with pixel-arty games.
  2. Leo-Yaik


    Unity Technologies

    Aug 13, 2014
    Thanks! We will keep them in mind.