I am trying to make a script enable on mouse over, so that a specific menu will work only if the mouse is on that specific object. When the mouse is not on the object the same button does a different action. Having trouble so I thought I’d come to the community for help
Here is the code so far:
var rightclickworking : int = 0;
function OnMouseOver () {
rightclickworking = 1;
}
function OnMouseExit () {
rightclickguiworking = 0;
}
function Update () {
var script1 = GetComponent(“RightClick”);
if (rightclickworking == 1) {
script1.enabled = true;
}
else if (rightclickworking == 0) {
script1.enabled = false; // <---- here is my issue
}
}
The error I am getting is: “Object reference not set to an instant of object” at line 15 and 18 where I specified.
This script is attached to the object and script1 is attached to the camera.
Could anybody help me with what I am doing wrong?