Search Unity

Custom IPackerPolicy cannot make use of SpritePackingRotation.Any

Discussion in 'Editor & General Support' started by Wisteso, Sep 11, 2015.

  1. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    5.2 has introduced a massively needed improvement to the Sprite Packer which is allowing rotation of sprites when packing them.

    It works great with the provided "TightRotateEnableSpritePackerPolicy" but Unity is still forcing a max size of 2048x2048 for some crazy reason, so we are forced to use a custom policy that bumps this up to 4092x4092...

    The problem is that passing a value of SpritePackingRotation.Any into PackerJob.AssignToAtlas gets ignored any treated as though you used SpritePackingRotation.None

    This means that sprite packing rotation is completely unusable for a large portion of people that need it.
     
  2. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    Posted this pretty late last night. Bumping for visibility.
     
  3. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    Figured it out.

    entry.settings.enableRotation = true; is required for packing rotation to be used. (where "settings" it an instance of AtlasSettings). Eventually this gets passed in to PackerJob.AddAtlas using LINQ sorcery (if you use the Unity template)

    PackerJob.AssignToAtlas() has a fourth parameter that can take SpritePackingRotation.Any, but should be ignored (at least for now) since it does nothing. Rotation will be done even if you pass SpritePackingRotation.None
     
  4. tzivaeris

    tzivaeris

    Joined:
    Mar 21, 2018
    Posts:
    4
    Can you please explain how you used a custom policy?

    This page here in unity

    https://docs.unity3d.com/2018.2/Documentation/Manual/SpritePacker.html

    shows that Sprite packer can have custom policies

    When I try to create the DefaultTexturePackerPolicy from the page I get

    Assets/SpritePacker/DefaultTexturePackerPolicySample.cs(8,14): error CS0535: `DefaultPackerPolicySample’ does not implement interface member `UnityEditor.Sprites.IPackerPolicy.AllowSequentialPacking.get’

    Is there an alternative way to do it?

    I need to increase it from 2048×20148 to 4096×4096

    Thank you