the system never detect my mouse/touch Click on a gameObject (the right or left arrow , check the below link)
public void OnMouseDown()
{
//don`t enter here!!
if (this.name == "gameObjectName")
doAction();
}
the system never detect my mouse/touch Click on a gameObject (the right or left arrow , check the below link)
public void OnMouseDown()
{
//don`t enter here!!
if (this.name == "gameObjectName")
doAction();
}
Since your instance variable name has the value "Left Arrow-50" the condition is false and your doAction-Mehtod does not get called.
It's difficult to help you, since we don't know what gameObjectName is. Is it a variable or a String?
if its a String variable, try the following code:
public void OnMouseDown()
{
if (this.name.equals(gameObjectName)) // - if gameObjectName is a variable, containing the name of game object
doAction();//never enter here!!
}
Assuming your script is attached to the Left Arrow-50 game object, first of all make sure both of them have collider components.
After that, rewrite your code removing the if line. Only the instance of your script that is attached to the clicked object will be called, so you don't need this line to check if this is the right object.
public void OnMouseDown()
{
doAction();
}
Do the same with the Right Arrow-50 and its script.