- Home /
object instances
I'm new to Unity and game making in general so forgive me if the answer to this question is kinda obvious. I have 2 instances of the same object. I want that when my mouse will hover over one of the instances that instance would change colour. But, when my mouse hovers over one of the instances both of them change colour and when my mouse hovers over the other instance of the object nothing happens. No change in colour.
Here are the scripts I used.
var Selec=false;
var MoOv=false;
function OnMouseEnter ()
{
MoOv=true;
}
function OnMouseExit ()
{
MoOv=false;
}
This one is for detecting the mouse over the background
var other : MoseOver;
function Start ()
{
other = GameObject.Find("Hexagon_grass").GetComponent("MoseOver");
}
function Update ()
{
if (other.MoOv == true)
{
GetComponent.<Renderer>().material.SetColor("_Color", Color.blue);
}
else if(other.MoOv == false)
{
GetComponent.<Renderer>().material.SetColor("_Color", Color.white);
}
}
and this one is for changing the colour of the border
I would really appreciate any help. Thanks in advance.
Comment