I want to highlight a gameobject only when mouse passes over it. I found a shader that works good when I assign it directly to the gameobject.
But if I assign a script to the gameobject in order to highlight it only when the mouse passes over it, the mesh turns pink.
I get the shader from: Unity 5.2.0 Outlined/Silhouetted Diffuse Shader problem - Questions & Answers - Unity Discussions
And this is the script attached to each gameobject to highlight:
using UnityEngine;
using System.Collections;
public class HighLighting : MonoBehaviour {
void OnMouseEnter()
{
gameObject.GetComponent<Renderer>().material.shader = Shader.Find("ImageEffectShader");
}
void OnMouseExit()
{
gameObject.GetComponent<Renderer>().material.shader = Shader.Find("Diffuse");
}
}