The Start() method performs two actions:
- Stores a reference to the MeshRenderer component in the _meshRenderer variable
- Stores a reference to the original material of the GameObject in the _originalMaterial variable
The cube is automatically sent the mouse enter/exit events as the user moves the mouse pointer over and away from the part of the screen where the cube is visible. Our code has added a behavior to the cube to change the material when these events are detected.
We can change the material for the cube by changing which material is referred to by the sharedMaterial property of the MeshRenderer GameObject.
When the OnMouseOver message is received, the method with that name is invoked, and the GameObject's material is set to mouseOverMaterial. When the OnMouseExit message is received, the GameObject's material is returned to _originalMaterial.
If...