I’ve got a (for my at least) unusual task at hand where I need to take an image and slice it into an array of small parts of that image so I can throw them around individually…
Sort of like in this video here:
Unfortunately for me, I’ve never really done anything similar so I am kinda drawing a blank here (and my google power has found nothing of value). Of course one way could be to slice it manually in a tool like Photoshop and than manually create the grid inside Unity - but this sounds highly ineffective to me and I was wondering if anyone of you guys knows perhaps of a more dynamic way.
Thanks
Are you doing it on the fly in runtime? Since you mention PhotoShop, i assume that is not the case. You could always import the image as a sprite, set the sprite to multiple, use the sprite editor’s grid slicing tool and slice away. That will divide the image into several smaller sprites that can be flung around as you want to…
I didn’t knew the sprite editor could do that. Then again - I’ve never used it yet. Thanks a lot for the pointer!
You, Sir, are amazing! I would have coded it myself with a few hints, but you just saved me the trouble. Thanks a lot for this!
This proves again that Unity indeed has a great community.
So, the script works quite like it should, but unfortunately I’m getting some weird border-artefacts on the new created sprites. I’ve tried every possible texture import setting but it doesn’t seems to be afflicting it. Unfortunately I’m really inexperienced with anything related 2D, so I’m drawing a blank again. Any help is immensely appreciated!
SOLVED: So, it turns out that the image was scaled down in the viewport since it was inside the editor and for some reason that created the artefacts. Problem solved itself when rendering in standalone and fullscreen.
Basically you don’t need to slice image to tiles to output it as tiles. You can just create grid inside 3d package and then assign it uv using ortographic projection.
For one our project I made a particle system where each particle was just 1 pixel of FullHD texture. I rendered it using geometry shader (~ 2kk particles) and procedurally calculated the UV for each particle (its coordinates divided by size in idle position)