Illuminating a 3D object's edges OnMouseOver (script in c#)?

Hi everyone,

I am new in coding and unity in general. I am working on a simulation, scripted in c#.

I want that when the player mouses over a 3D object the edges of the 3D object Illuminate as a green or blue line (not that the color really matters in code). Is this possible to do? and if it is, how would I do that?

This is what I have now:

using UnityEngine;
using System.Collections;
    
    public class myscript : MonoBehaviour {
    
    private Color initialColor;
    
    	void Start()
    	{
    		initialColor = renderer.material.color;
    	}
    
    	void  OnMouseOver ()
    	{
    		renderer.material.color = Color.green;
    	}
    	
    	void  OnMouseExit ()
    	{
    		renderer.material.color = initialColor;
    	}
    }

It works but what happens with this code is that you just change the main color of the texture and that is not what I want.

Thank you in advance for your input!

You’re changing the colour of the object, not rendering an outline around it. Rendering outline is not easy. One way to do this is to move the object closer to the camera, and render it with a flat shader. Do this without writing to the z-buffer. Then render your object normally, at the correct position. You should then have the flat shaded edge showing. (Moving the copy closer to the camera makes it larger.)