i’m making the main menu of my game. It consists of cubes that have scripts on them OnMouseEnter that makes it turn green, OnMouseExit that makes it go back to white, and OnMouseDown which switches cameras. In unity, when the mouse in over the cube, it works right. In the build version though, my mouse will be far to the left, and the cube will be green. Even though I’m nowhere near the cube.
In this picture, you can see the “Controls” option on the main menu is green. My mouse is directly over it. As it should be.
In this picture, you can see the “Controls” option on the main menu is green. My mouse is not directly over it. This isn’t right. Why? Please help!
Try this, assign the object to the script
public GameObject play;
public GameObject credit;
public GameObject control;
public GameObject purpose;
public GameObject TSA;
public GameObject Quit;
public Texture playnormal;
public Texture creditnormal;
public Texture controlnormal;
public Texture purposenormal;
public Texture TSAnormal;
public Texture Quitnormal;
public Texture playactive;
public Texture creditactive;
public Texture controlactive;
public Texture purposeactive;
public Texture TSAactive;
public Texture Quitactive;
void resettexture()
{
play.GetComponent<Material> ().mainTexture = playnormal;
credit.GetComponent<Material> ().mainTexture = creditnormal;
control.GetComponent<Material> ().mainTexture = controlnormal;
purpose.GetComponent<Material> ().mainTexture = purposenormal;
TSA.GetComponent<Material> ().mainTexture = TSAnormal;
Quit.GetComponent<Material> ().mainTexture = Quitnormal;
}
void OnMouseDown()
{
resettexture();
if(gameObject.name=="paly")
{
play.GetComponent<Material> ().mainTexture = playactive;
}
else if(gameObject.name=="credit")
{
credit.GetComponent<Material> ().mainTexture = creditactive;
}
else if(gameObject.name=="control")
{
control.GetComponent<Material> ().mainTexture = controlactive;
}
else if(gameObject.name=="purpose")
{
purpose.GetComponent<Material> ().mainTexture =purposeactive;
}
else if(gameObject.name=="TSA")
{
TSA.GetComponent<Material> ().mainTexture = TSAactive;
}
else if(gameObject.name=="Quit")
{
Quit.GetComponent<Material> ().mainTexture = Quitactive;
}
}
void OnMouseExit()
{
resettexture();
}