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. Dismiss Notice

Problem with UI Outline script

Discussion in 'UGUI & TextMesh Pro' started by Flightkick, Mar 12, 2015.

Thread Status:
Not open for further replies.
  1. Flightkick

    Flightkick

    Joined:
    Feb 6, 2015
    Posts:
    3
    Hey all,

    I've got a problem with the build-in outline script. I am trying to get a red border around an item slot. Therefor I am using the Effect Color property, however, it doesn't matter which color I select. The border stays black.

    paintskillz.png

    I am using Unity 5.0.0f4 Personal.

    Is this a bug or am I doing something wrong?

    Thanks in advance.
     
  2. Flightkick

    Flightkick

    Joined:
    Feb 6, 2015
    Posts:
    3
    Found it. It seems like the effect color is more like an intensity channel (can't come up with the official name for it).
     
  3. Pharan

    Pharan

    Joined:
    Oct 28, 2013
    Posts:
    102
    The Shadow effect actually just creates a copy of the vertices showing your sprite and draws it underneath: https://bitbucket.org/Unity-Technol...e.UI/UI/Core/VertexModifiers/Shadow.cs?at=4.6

    The Outline effect does the same thing, just four times. (adds a shadow upward, downward, left and right)
    : https://bitbucket.org/Unity-Technol....UI/UI/Core/VertexModifiers/Outline.cs?at=4.6

    So if your sprite has teal pixels, it will draw teal pixels if you set your color to white. Notice how the color will behave the same if you set the same color on your Image component.
    That's how vertex colors for most shaders (including the UI's shaders) work: Multiply.
    These effects work okay with the standard asset sprites because they are white. And they work with Text because generated font textures are white. In those instances, white is white, black is black, red is red.

    What's happening in your case is that teal is being multiplied by red, which usually ends up a very very dark color: that's what happens when you multiply two kinda complementary colors.

    Recommendation:
    (1) Use a white box asset instead of a teal one. Make it teal using the color property in the inspector. Then your outline effect color should work as expected.
    or...
    (2) Just not use the Outline effect and, and make your own custom outline asset.
     
    SimonDarksideJ and Flightkick like this.
  4. Flightkick

    Flightkick

    Joined:
    Feb 6, 2015
    Posts:
    3
    Thanks for the explanation! Helps a lot.
     
  5. Jet27

    Jet27

    Joined:
    Apr 11, 2017
    Posts:
    1
    Wow, a graphics engine that doesn't know what an outline is.
    That is embarrasing!
    "Oh, well, four shadows is the same as an outline, right?"
    Not if your shape has detailed alpha! Holy crap, UNITY IS GARBAGE!
     
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,057
    Please try not to necro old threads...

    The outline and shadow component are just easy implementations that work for most sprites that are used as panel or barely use alpha.
    It ain't easy to create an outline for an Image component that is not made out of vertices like a 3D mesh is.
    The vertices of an Image object is just a square mesh with a sprite as texture simply said. To calculate an outline you'd normally want to take the vertices and normals and extrapolate an outline out of it. With Image components you just can't.
    Those are just technical limitations, it doesn't mean that Unity is garbage. But if you're so smart and know all how to do it better, go ahead and create an asset for it. But I think you don't know, else you wouldn't be searching off the forum for a solution.

    A little bit of respect to developers would be nice instead of just going around and raging like a little kid.
    Sure things aren't always optimal, but nothing is perfect. I'd be surprised if your solutions are all perfect.
     
Thread Status:
Not open for further replies.