Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Create a single sprite using multiple sprites (Merge multiple sprites into single sprite)

Discussion in 'Scripting' started by Lt_Dank, Jan 4, 2017.

  1. Lt_Dank

    Lt_Dank

    Joined:
    Jan 4, 2017
    Posts:
    4
    Hello everyone,

    I want to create a single sprite using Unity Scripting, i am accessing a parent object containing all the children objects spriterenderer.

    I want to create a single sprite of all those children objects containing sprite renderer, with respect to their positions.

    I am able to access only one sprite and use it, but not able to merge it into single sprite.
     

    Attached Files:

  2. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    You may want to box them in an empty game object.

    It has virtually no hit on performance versus trying to make them one single texture.

    Then all the sprites will inherit the parent object.
     
  3. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Great question...

    I think for UI each single texture will cause draw calls plus more memory in final build size
     
  4. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    Not with an atlas.
     
  5. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I think that's what he want to create with those all sprites..Merge them onto single atlass....
     
  6. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    Ah.

    Yeah, I just did that in GIMP and manually cut out the sprites.

    Just remember to use a square with sides that are a power of 2.

    2
    4
    8
    16
    32
    64
    128
    256
    512
    1024
    2048
     
    slanavoda and idurvesh like this.
  7. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Great...I am planning to do tonight.....DId you manually placed all sprites in single atlass or there is any plugin available which does the job?
     
  8. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    A quick search on google shows there are tons of plugins, though I am not sure if any are any good (there are virtually no reviews/scores/comments for them :/

    Personally I use Photoshop and just do it manually (if the separate sprites are already sized properly it's pretty trivial). Though you can also check out TexturePacker
     
    MGGDev and idurvesh like this.
  9. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    Yeah, pretty much.

    There's a few thing that are just simply easier to do on your own than try and use a plug in.

    Sprite atlases and prefab atlases both come to mind.

    For the sprite atlas, just take all the sprites you'll use in an area and throw it on a 1024 x 1024 png file.

    PNG is the fastest for sprite, btw.

    Also, make sure to use point rendering if you want it to be pixalized and not blurry.
     
    idurvesh likes this.
  10. Lt_Dank

    Lt_Dank

    Joined:
    Jan 4, 2017
    Posts:
    4
    Yes, basically i'm doing the same thing. So i want to create a single sprite from all those already placed children Sprites in the scene. So that i can manipulate in the game to perform a function using Image(Script) object.

    You can check out the attached images to find more information on the problem. :)
     

    Attached Files:

  11. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I ended doing same, created 1024 size png .

    Just to be sure you talking about "Point" filter mode ,right?
     
    Not_Sure likes this.
  12. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Yeah point filter. Otherwise you get some aa done and increase the chance of tearing when tiling sprites.