[SOLVED] GameObject picking -- highlighting and outlining

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?

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.)

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”);
}

260643–9367–$self_illuminated_outlined_diffuse_113.shader (1.91 KB)

3 Likes

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

1 Like

Did you find a solution to your problem?

1 Like