Hi! I need some instructions regarding Sprite Atlases.
I created a Sprite Atlas and put some Sprites on it. Clicked Pack and Ok, now I have my Sprite Atlas.
But a have some questions :
In Design Time, if I assign a Sprite to a SpriteRenderer, it will use the Sprite from the Atlas? How I can be sure of this?
I was using Packing Tags for these Sprite Before, if these Sprites are all now on a Atlas, unity will not Pack these textures anymore and use only the texture from the Atlas?
I love this new feature, but there is no much documentation about it yet. Until Unity 5.6, I did use List to make something similar, but I’m sure the native Atlas will work a lot better. I’m using it on a new game which should be ready very soon.
When using Sprite Atlases, after enabling them changing from Editor - Preferences - Sprite Packer Always Enabled (Legacy Sprite Packer) to Editor - Preferences - Sprite Packer (Always Enabled), Unity will ignore all the previous sprite settings (the Sprite Packer Window will be Disabled) and only use the Sprite Atlases you created.
These 2 questions remains :
1 - Unity UI Image does not support Rotated and Tighter Sprites?
2 - GetSprite return the sprite with the name you asked+(Clone). I don’t see a reason for it. As a workaround I’m using :
UI only uses square Sprites. This is because UI always tessellate it’s geometry in quads.
The reason for this is deep. Because Sprite has an internal reference to only 1 atlas, this limits how how many atlases it can be on. In other words, You can’t put Sprites into multiple atlases because it can only remember one atlas at a time.
However, we make it so that you COULD duplicate your sprites into multiple atlases (because you know exactly how your scene is rendered and you want to optimize it for minimal drawcalls). But to make it so that your Sprite reference the right atlas, we chose to clone it so that it will always point to the atlas where you retrieved the sprite.
I’m just getting into playing with the beta and this answered my questions on this topic. One other thing - since sprites are referenced by name (seemingly by an internal name->sprite mapping) we have to be careful of duplicate sprite names. So I performed a little experiment. I created an atlas.
I added a folder with a bunch of sprites, one of which is named “Green”. I did this by dragging it into the component. Switching the inspector to Debug mode, I see that there’s an array of sprite names, etc.
If you drag a duplicate item from the same folder it does not get added - makes sense. But if I add a different item from a different folder with the SAME name it does.
After packing, Problem is that I now have two sprites with identical names. At runtime I’d imagine that trying to access “Green” would always return the sprite whose name appears in the name->sprite mapping. But that seems to change depending on the packing. But the names ARE duplicated.
Further, if I keep dropping the same sprite on the atlas component I get multiple entries in the “objects for packing” area. Although they aren’t packed more than once, this ought to be an error to the user.
So I’d think that the atlas component ought to give errors to the user when s/he tries to add a sprite with the same name. And it ought to ignore multiple attempts to add the same sprite to the “Objects” list.
As I’m writing this I realize that I ought to make a bug report… duh
anyway, note the image below: multiple instances of the same thing. Multiple instances of identical names.