Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] GameObject picking -- highlighting and outlining

Discussion in 'Scripting' started by Nick-Wiggill, Feb 2, 2010.

  1. Nick-Wiggill

    Nick-Wiggill

    Joined:
    Jan 31, 2010
    Posts:
    46
    I've figured out some basics on how to use OnMouseOver as well as raycasting techniques to interact with collidable objects.

    Now what I want to do is something like what you'd see in Dungeon Siege or Fate (correct me if I'm wrong on either count)... where moving over an object does 2 things:

    1. Highlights the object by applying a sort of "maximum" or increased level of lighting to that object only;

    2. Outlines the object with a vectorised set of lines, eg. in bright green, to show it up clearly.

    I have some idea that the first may require me to mess with materials or layers, but as to the second, I have no idea.

    Thoughts?
     
  2. Nick-Wiggill

    Nick-Wiggill

    Joined:
    Jan 31, 2010
    Posts:
    46
    Quick update, this is looking promising. What is needed is a Self-illuminated Diffuse shader (yours may be something other than diffuse though) combined with toon-shading outlines.

    I've gotten each to work separately, they look great; now I need to combine them in one single Self-illuminated Outlined Diffuse shader.

    My sources of information, thanks to OPs:

    http://forum.unity3d.com/viewtopic.php?p=264226#264226 (custom "Outlined Diffuse" shader, thanks go to Omega)
    http://forum.unity3d.com/viewtopic.php?t=21623 (ensuring outline thickness is consistent with viewing distance)

    Another option might be this, which will presumably allow highlighting using only Omega's custom shader, meaning no custom "Self-illuminated Outlined Diffuse" needs to be made:

    http://forum.unity3d.com/viewtopic.php?p=235628

    (I can't comment on the quality of that method though as I've not tried it.)
     
  3. Nick-Wiggill

    Nick-Wiggill

    Joined:
    Jan 31, 2010
    Posts:
    46
    Ah, I got this going a few days back and wanted to share with all of you since it's really the work of others I've stitched together... it was laughably simple, but this may save someone the hassle of even thinking about it. See new shader attached.

    Just make sure it's accessible somewhere in your /Resources folder, then use a script like this to test it:

    function OnMouseOver()
    {
    renderer.material.shader = Shader.Find("Self-Illumin/Outlined Diffuse");
    }

    function OnMouseExit()
    {
    renderer.material.shader = Shader.Find("Diffuse");
    }
     

    Attached Files:

    PK-Link, yusufsermet and hassank like this.
  4. pippin_mole

    pippin_mole

    Joined:
    May 26, 2015
    Posts:
    10

    Ok - First thing's first, this post is 7 years old, i apologise - But the link have expired, and when i do "onmouseover" ingame, the cube just turns white

    Can you help me?

    http://imgur.com/a/wyD1f
    Before and after when onmouseover

    I think its to do with the Illumin(A)
    http://imgur.com/a/bSHBT
     
    George-Dolbier likes this.
  5. Totoro205

    Totoro205

    Joined:
    Dec 12, 2017
    Posts:
    18

    Did you find a solution to your problem?
     
    vincewins likes this.