I’ve read several of the questions on this site pertaining to making 3D objects glow, highlight, etc when the player moves the mouse over them, and the example scripts provided appear to be what I’m looking for, or close to it. My question is this: I have a 3D neon sign on my title screen, created in 3DS Max, that I want to light up when moused over. It wasn’t created using Unity’s GUI tool (would it be easier or harder that way, considering it’s a prefab currently?) I’ve tried attaching the script mentioned several times when explaining how to use the OnMouseOver or OnMouseEnter script, but I get an error saying that I don’t have a renderer attached with which to render a new color to my neon sign.
Long story short, does anyone know what the best way to go about scripting this sign to light up realistically when the player mouses over it would be? I’m not unfamiliar with Unityscript, and I have seen all the tutorials, I think this is just a matter of a few different mental dots I need to have connected for me by devs who are more experienced. I’d really appreciate the help.
(Edit) The script I’ve been trying hardest with is:
var initialColor : Color;
function Start()
{
initialColor = renderer.material.color;
}
function OnMouseOver()
{
renderer.material.color = Color.red;
}
function OnMouseExit()
{
renderer.material.color = initialColor;
}
Here is the link to the question I found that script in. Although it’s informative when I think about how it should work, the error I get is:
MissingComponentException: There is no ‘Renderer’ attached to the “NeonSign” game object, but a script is trying to access it.
You probably need to add a Renderer to the game object “NeonSign”. Or your script needs to check if the component is attached before using it.
glowNeon.Start () (at Assets/glowNeon.js:5)
The error message is clear enough, I need to add a renderer to my GameObject. But I suppose this is where my experience level tapers a little. Are there multiple types of renderers? Which one do I need?
(Edit)
Here’s the hierarchy and inspector panel from my project.
I added an experimental cube next to my neon sign, and attached the same script I used to animate the neon glow, and it works exactly the way it should. I edited a couple lines, to allow me to specify the initial color as well as the color it turns when the mouse hovers of the the object. It works perfectly on the cube, but still has no effect on the neon sign. It stands to reason that it’s something with the sign mesh, or the renderer, or something, since the script works. I’m totally at a loss with this thing.