Working on creating a 2d lvl procedurally i instantiate a lot of sprite of size 32*32.
And i was wondering if it’s possible to combine all the sprites next to each other (wich are the same into one) ? if it’s relevant to save ressources or if it’s unecessary ?
Yes if you have hundreds of sprites which all have different materials(and/or textures) then the performance hit will be big on mobile.
Unity does Dynamic batching for you where it sends batches of meshes to render. It collects several meshes until it reaches about 900 verts in total and batch it to 1 draw call. So it would batch 225 sprites in 1 draw call, on condition they use the same material.
If you’re using Unity 4.3 or above, you can import a sprite sheet from texture packer and make unity recognise it as as sprite sheet by selecting ‘multiple’ in the import settings. The instantiated sprites are automatically batched at runtime.
Also make sure you don’t use Instantiate too frequently, consider using an object recycler if possible.