Search Unity

Sprites on scene/prefabs keep changing when I edit the spritesheet.

Discussion in '2D' started by AlanGameDev, Jul 15, 2014.

  1. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Hello there.

    I have a 'wip' spritesheet and the first thing I've mapped there was the player sprite and named it 'player'. I've assigned that sprite to a SpriteRenderer component. When I added some guns to the spritesheet and mapped them using the built-in editor, the sprite of that SpriteRenderer was changed to a gun (so my player now were a gun with legs made of bullets). I've changed all the sprites back to the proper ones, assuming it was a bug or something. However, I've mapped some trees and bushes on the spritesheet and again, my player changed into a tree...

    I would like to know how I can avoid that. It's extremely frustrating to map the whole shebang all the time and I couldn't find what is causing the sprites to change since not all of them changes, only some. I thought the sprite would remain the same as long as you don't rename it but that's not the case... Unity doesn't seem to use the name to identify the sprites because I've never renamed the 'player' sprite and still the sprite in the SpriteRenderer component changes.

    Any help is appreciated.
     
    Last edited: Jul 16, 2014
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    If I recall, I think the association is by a numeric index not name, so adding may cause things to mis-associate.

    My advice (though not a technical solution to that issue of reordering) is either use the built in sprite packer, or an external solution like texture packer. Basically, don't ever manually manage a sprite sheet. Automate it in some way. Or even just keep them all as separate images until you are sure they are final, then pack them.

    Manually editing sprite sheets/atlases leads to frustration and sadness and can damage your soul. (at least in my experience) ;)
     
  3. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
  4. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Texturepacker is good but it doesn't support pivot points, otherwise I'd surely use it.
    Thank you!

    I'm still using 4.5.0 and for some reason it won't find the new update(s) on the web... that's very minor though and I can't help but say: you guys are quick! I've downloaded the 'all new' 4.5 like 2 months ago and you've already rolled out two versions! :) Awesome!
     
  5. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Just a small update since I'm being contacted about the issue:

    After updating to 5 I've edited the hell outta the spritesheets and it never happened again! In any case I always zip the meta file after substantial edits just to be on the safe side :).