- Home /
How do I take part of a large spritesheet and split it into a number of smaller ones?
I have one big spritesheet which has enemies, player, objects, platforms etc. on it in one block.
I want to separate out player sprites, enemy sprites, ground sprites etc. into different objects/textures.
How do I do this?
Answer by TomMakesGames · Feb 08 at 02:29 PM
So, coming back here after doing something else and realising the solution....
You can have one spritesheet like shown. Use the sprite editor to slice it up. Then select which frames you want to use in an animation Create animations, animators etc. with those frames. You can still use a sprite to represent your stationary player/npc in the scene. You can also select and then drag and drop those sprites onto the tilemap and paint them into the level. You can also assign sprites to different objects, all from the one sheet.
All these are different objects, but they are all referring to the same sprite sheet for their visual appearances.
I didn't realise this was so easy until just now. And as others say - this should be more performant.
Answer by privatecontractor · Jan 20 at 01:24 PM
Hi @TomMakesGames ,
(1) From point of rendering graphic (reducing amount of draw calls) having biger texture with many small inside is beter than having few... but if you need edit it totally and cut to few separate files use Gimp, Paint... etc
(2) If you have one file with many small graphics, try to use sprite mode Multiple and map sprite for different objects... it's really simple and will allow you to optimise your project
When you select sprite in Unity, change SpriteMode to Multiple. Then hit SpriteEditor bellow.
If you don't use it already, will need to import it. Use option Slice, and chose size, etc.
When you finish, in unity resources when you click edited sprite, will you have all of the cuted sprites... And gest bart is than graphic cart will try to render them together.
Hope that help.
Answer by TomMakesGames · Jan 20 at 01:32 PM
Hi @privatecontractor, and thanks for replying.
I know how to do all of that - the importing, slicing etc. But then I end up with 1 big spritesheet with 400 or so sprites in it.
But how can I separate out the player character sprites to go with a player character gameObject? Or the enemy? Or separate out the background, foreground tiles etc.
In another scenario, I might have downloaded 15 frames for a player, another 20 frame sprite sheet for an enemy, and so on. But here they're all included in one massive one. I get the point about draw calls. So is there a way to point/reference certain frames/sprites in this one spritesheet from another object then? Is that the best way? Or am I better off just manually dividing this up in GIMP etc.?
I've attached what I had already. But what's the best way to partition this out for the various functions represented here?
Hope that all makes sense!
Hi @TomMakesGames,
So is there a way to point/reference certain frames/sprites in this one spritesheet from another object then?
Look at picture from my screen, this is one big sprite cuted as we speak above. have all of pieces listed and can use them for serialization in different parts of project. Just drag selected and drop to [Serializedfield] Is this what you looking for? https://ibb.co/GsKbRRQ
Is that the best way?
Depends from loots of staff: (+) prefered to having single file for character (like player/ enemy type) it easier to manage (add remove, etc...). (+) always trying to have all of sprites of particle systems in one file for one materia (-) Of course each file will generate new draw call
Or am I better off just manually dividing this up in GIMP etc.?
Don't know your project, I having player character frames in one, enemys in second file (each have 4 frames- sprites for 4 direction) works perfectly.
You can always check both solutions and check what running smoother or designated machine/ platform.
Hope that helped
Hi there, been ill so couldn't return. I think it might be easier to just cut up the file into separate bits.
But I was hoping that there was some way to have gameobjects within Unity reference just certain frames within the sprite sheet. i.e. There's one file, but then you have a sprite which is actually frames 50-60 for the player, another sprite which is frame 10-20 for an enemy etc.
I looked at sprite maps, but that doesn't seem to be what I want.
Your answer
Follow this Question
Related Questions
Is there any benefit to slicing in power of two dimensions inside a sprite sheet? 1 Answer
add animation frames to existing spritesheet with animations? 0 Answers
Unity 2D problem with displaying sprites in final build game 1 Answer
Turning GIFs to spritesheets IN UNITY 1 Answer
How can I key out (remove) a color from a spritesheet (2D)? 1 Answer