Use the same Plane mesh asset for multiple dynamically created prefabs

Hi, I have a script which takes in a full spritesheet and spits out a textured “plane mesh” to file for each sprite on the sheet. I then save out a prefab object via code which uses this plane mesh. This means I can simply drag in a texture atlas into my custom window and it gives me a ready made textured plane with the correct sprite on it to drag into the scene.

This is great and exactly what I wanted, but I need to think about performance etc. I am wondering if it is possible to use only a single “plane” mesh within multiple dynamically created prefabs, but each mesh being able to manipulate that meshes vertices/UV coords individually. I assume Unity has some Instancing enhancements for meshes of the same type so correct me if I am wrong, but I will save alot of HDD space and RAM if I just use 1 single plane mesh instead of my current version where each sprite will produce its own custom plane.

I did attempt to do this and it ended up with each plane that my script produced were exactly the same dimensions and had exactly the same UV coords.

Thanks for reading.

Those are two contradictory things. If it’s a single mesh then by definition it can’t have different vertices or UVs for different objects.

A mesh quad uses a trivial amount of space.

–Eric

Hi, thanks for the reply. If I do it like that though, where I save out the newly created quad won’t that then be seen as a separate mesh and the amount of drawcalls will increase if I end up with a large amount of sprite assets needed?

Draw calls come from materials moreso than meshes.

If you have separate meshes, they generate separate draw calls even if they have the same material, unless you use dynamic batching. For best efficiency you’d make a sprite system using the Mesh class so that many sprites are combined into one mesh, using a texture atlas.

–Eric