Search Unity

Best practice for image size for 2D modular art

Discussion in '2D' started by CensedPie, Aug 3, 2021.

  1. CensedPie

    CensedPie

    Joined:
    Mar 31, 2018
    Posts:
    2
    I am designing 2D art of weapon parts for my game and I have found two options for creating the art and I don't know which to pick. I want to be able to switch parts in and out later to customize the gun.
    The first option would be to have the a 2D image size such as 256 by 128 and create all the weapon parts as separate layers then export each layer as its own image. This would mean that when the images are at the same position they would form a gun out of parts.
    The second option would be to have different sized images for each part depending on how big the part is and assemble them by positioning them differently.
    My main concern with option one is that I would be wasting memory to store all the textures even if it seems like a little, overall it adds up. My concern with the second option is floating point errors can result in wrong positioning for parts making the weapon look shaky when moving.
    I have also thought about making all the parts separately then combining them in one atlas image to save space but I am unsure again with the floating point error and do not want a shaky gun when moving around.
    What would be the best practice for this situation? If there are any other ideas other than the ones I presented I would love to hear them.
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    Hey,

    You can use the first method without wasting memory by making use of Unity's built in sprite atlas feature: https://docs.unity3d.com/Manual/class-SpriteAtlas.html

    You can also use the PSD Importer package to import a PSB file, which will have all of the layers in the correct positions and sorting orders by default.

    I use both methods, and I find they work quite well. I haven't done any optimization tests though, but as long as you don't add bones to the PSB file, I don't think performance will be an issue.
     
    CensedPie likes this.
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511