Sprite sheets are essential to any Unity project. Whether it be a character sprite sheet, UI, or anything else, you will find yourself with one in your project and it will change over the lifetime of the project. Updating you spritesheet can be catastrophic if not done properly.
For example, suppose I have this arrow key sprite all of which I have named appropriately in the sprite sheet.
I add these sprites to some images in my UI, but it seems forgot the up arrow sprite. I’ll just add that and overwrite my image file in the project.
Scene view of my arrows.
With the up arrow added, I slice my sprite again but the sprite names were overwritten and I lost reference to these sprites in the scene!
Slicing the sprite sheet and losing sprite information and reference.
Scene view of my arrows. Sprite references are now null so I lost my arrows.
If I update my sprite sheet, I don’t want to have to re-establish references to my scene objects or my animations. That would be a ton of extra work. Good thing there’s workflow just for this and its called Smart Slicing.
Smart slicing is an option in the sprite editor window.
Smart slicing my arrows sprite sheet.
Smart slicing keeps all the existing sprites along with their names and scene references, while finding the new ones too! Now I can add the final arrow to my scene.
All arrow sprites in my scene
However, I have decided that I want a second set of arrow sprites, but I want to use the same sprite sheet, so I add another row of arrows in my image manipulation program, and re-export my image.
But now all my arrow sprites in my scene have changed! They have the same names but they are using the same references to the old sprites!
Arrows with sprite image overridden, but metadata persisted.
This happened because Unity looks at the sprite sheet from the bottom left pixel of the image. Because I put my new set of arrows underneath the original set, Unity used that same bottom left as a reference and used the green set of arrows. Even re-slicing with smart settings won’t fix this.
Instead, if I add the green arrows above the original set, I will achieve the effect I wanted, maintaining all preexisting information.
Summary
This was a bit longer of a post and perhaps a bit more confusing, but the main takeaways are:
Use smart slicing in the sprite editor
When adding a new row of sprites to your sprite sheet, add them above the existing sprites. Not below