- Home /
Renderer and Color are unknown to unity. Why?
When I write or download a script things like 'renderer' and 'color' are coming up with errors once loaded into unity.
Example:
function OnMouseEnter()
{
renderer.material.color = color.white ;
}
This then in unity it says 'unknown identifier color' / 'unknown identifier renderer'. Sometimes this error appear using other identifiers. I'm using Free Unity 3D 3.5.5f3.
If renderer is null. Are you sure there is a renderer component on the game object? If there is but then disappears, then I don't know, maybe some other code is removing it.
.color would be null if there is no material.
Answer by dannyskim · Sep 29, 2012 at 04:41 PM
Lower case is typically when you want to access the member, and Uppercase is when you want the actual class.
In the case of the color on the right hand side of the statement, it should be Color.white since you're trying to access the white member of the class Color.
As for the renderer not being recognized, not quite sure.
TYS$$anonymous$$!!!! It didn't make errors. but I'm still left with with a problem : when I move my mouse on the object Its now saying shader wants tangents, but the mesh doesn't have them. Why? TY =]
It is also saying:
NullReferenceException: Object reference not set to an instance of an object
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers