Search Unity

Question How to fill up a closed area within a sprite with different color?

Discussion in '2D' started by raining_day0513, Oct 20, 2020.

  1. raining_day0513

    raining_day0513

    Joined:
    Dec 3, 2019
    Posts:
    9
    Me and my team want to create a game with a key feature that we want that our main character to have an ability to change the details of objects by color during the game. We are all new to Unity so we don't know what's the best way to do this, considering performance / technical complexity, or so. Regarding "fill up a closed area within a sprite with different color":

    1. The sprite here is generated from a sprite sheet.
    2. Fill up a closed area means that say the sprite wearing a hat, and we don't want to change color of the entire sprite, say a cat(no accessories) + the hat it's wearing (accessories), but only the hat.​

    Is this possible for a sprite-sheet-created character (I guess since each pose of the character in the sheet is rendered single-layer)? Or I have to have multi-layer character, i.e. the cat using a single sprite sheet and those accessories using other ones?
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    you can use texture2d.getpixels to search for the colors of the hat and change them. this needs the hat color not to be anywhere else in the cat. Think like the magic wand tool in photoshop
     
    raining_day0513 likes this.
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    This series has a lot of the techniques you'll need:



    Yes, you'd have a spritesheet for the character, then a sprite/sheet for the accessory. That's two SpriteRenderers.