Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Replace color in specific sections in sprite

Discussion in '2D' started by arthuronoszko, Apr 6, 2017.

  1. arthuronoszko

    arthuronoszko

    Joined:
    Feb 24, 2016
    Posts:
    21
    Hello!

    I have some sprites that look exactly the same, except for the colouring. So far, I have made an atlas of the sprites, coloured them white, and the set the color in SpriteRenderer to match the original illustration. I feel that I am doing a lot of extra work for this, and am wondering if you guys have any tips of how to achieve this in a more efficient way.

    For example, I have two horses. They have the exact same vectors, except for the different colors. Look at horse-pink.png and horse-yellow-green.png

    I want to do this more efficient in order to have less amount of textures in the game, to make the build size smaller. Maybe there is another solution to this that I am not thinking of?

    Thank you for your help!

    BR
    Arthur
     

    Attached Files:

  2. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    130
    Divide your sprite into parts depending on their colors, like this:
    horse.png
    Set sprite mode as multiple, cut these two elements into two separate sprites in sprite editor.
    In your scene place them one on top the other and connect them by parenting.
    Now you can recolor each of them independently.
    This is the easiest way.
    If you want to use shaders for that, then you should read this thread: Link
     
    theANMATOR2b likes this.
  3. arthuronoszko

    arthuronoszko

    Joined:
    Feb 24, 2016
    Posts:
    21

    Thank you for your answer 1Piotrek1. That is how I thought I was gonna do, and it feels better to have some confirmation that you thought of the same solution :)