What i am trying to do is Change all of the GameObjects that are children of a certain GameObjects color. The problem i am having is that when i try to store the original color of the GameObject i am trying to change, i get an Error: NullReferenceException: Object Reference not set to an instance of an object.
But here is the code :
` private var menuCube : GameObject[]; private var mainColor : Color; function Start() { menuCube = GameObject.FindGameObjectsWithTag("MenuCube"); mainColor = menuCube.renderer.material.color; } function OnMouseOver() { menuCube.renderer.material.color = Color.green; } function OnMouseExit() { menuCube.renderer.material.color = mainColor; } `
The Error shows up at line 8:
` mainColor = menuCube.renderer.material.color; /* This line is where the error is pointing */ `
Just to clarify i intend this script to be attached to the parent object.