- Home /
Highlight gameobject
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: http://answers.unity3d.com/questions/1068089/unity-520-outlinedsilhouetted-diffuse-shader-probl.html
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");
}
}
Answer by tanoshimi · Sep 23, 2016 at 10:49 AM
Assuming you've copied that code exactly, you want to use:
Shader.Find("Custom/ImageEffectShader");
Your answer
Follow this Question
Related Questions
The Best Way to Highlight An Enemy 0 Answers
How can I make rim lighting appear in front of everything? 1 Answer
Better Performance for 2D game 0 Answers
What are shaders 1 Answer
Prefab's High poly mesh VS lower poly transparency cutout 2 Answers