Search Unity

Highlight sprite

Discussion in '2D' started by Keenkhar, Oct 16, 2017.

  1. Keenkhar

    Keenkhar

    Joined:
    Oct 24, 2016
    Posts:
    8
    Hello,
    I'm new with unity and i'd like to color a sprite with a color (with transparency).
    Here is a sprite

    But if i use the color parameter in the sprite renderer, i obtain this :


    But this is not the effect i want (the blue become black, and if i change the alpha, it is the whole sprite that become transparent)

    I want to get this instead :


    How can i do this (here i use red color, but i want to be able to change this color while the game is running) ?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    If just changing the sprite color doesn't suffice, then you'll probably have to write (or find) a custom shader.
     
  3. supermoof

    supermoof

    Joined:
    Sep 24, 2015
    Posts:
    48
  4. Keenkhar

    Keenkhar

    Joined:
    Oct 24, 2016
    Posts:
    8
    Thx for your comments.

    I had a look at shaders and it seems to be a little too complicate for me for the moment :p
    I'm learning unity and i prefer to focus on "basics things" and master them before using more advanced options.

    I think i will change what i planed, and adapt my game for use the color parameter of the sprire renderer.

    When my game will be finished, i'll improve graphics with shaders.
     
    JoeStrout likes this.
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    That's a good plan. You can easily get sidetracked on something like this, as some small feature turns out to be as hard as the rest of your game! Better to just adapt and continue, especially at first.