Breaking Up Sprites to Pieces During Runtime in Unity

Posted by Mark Marcikic, on February 20, 2017

How do you cut a sprite to pieces during runtime in Unity?
I'll show you a simple method for it, where you take an object's sprite, divide it and make every piece a child object of the original.

The script needs two inputs, one is the "size", where we specify how many pieces we want to divide the sprite to. The other one is the "PPU", where you should enter the sprite's Pixel Per Unit (100 by default).
The script retrieves the GameObject's sprite, cuts out pieces from it and assigns them to the child objects. Once a child gets its own little sprite, it's moved to the correct position. Finally, the original sprite is removed.

Copyright © Brute Drop 2017