Hi, I Am writing a code in c# here is what I have at the moment
using UnityEngine;
using System.Collections;
public class MouseOver1 : MonoBehaviour {
void OnMouseEnter(){
renderer.enabled = false;
}
void OnMouseExit(){
renderer.enabled = true;
}
}
--------------------------------------------------------------------------------------
Im recieving those 2 errors when using the mouse over the cube
NullReferenceException: Object reference not set to an instance of an object
MouseOver1.OnMouseEnter () (at Assets/MouseOver1.cs:7)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)
--------------------------------------------------------------------------------------
NullReferenceException: Object reference not set to an instance of an object
MouseOver1.OnMouseExit () (at Assets/MouseOver1.cs:11)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)
----------------------------------------------------------------------------------
The code is indeed attached to the cube or what ever else I try with and the object has a collider. I do not understand what is missing thank you for helping me I am really stuck and I am only at the 1st lines of script in my game :S
↧