Hi, im newbie.
Run class run attached to the camera object.
public class Run : MonoBehaviour
{
MyClass s;
public int INCREMENT_TAP;
void Awake()
{
s = new MyClass();
}
void Update() { // show INCREMENT_TAP }
}
And in a gameobject, a quad called “Tapping”, this script is attached
public class Tap: MonoBehaviour
{
void OnMouseDown()
{
// Want to INCREMENT_TAP++; How can i access to Run.INCREMENT_TAP ? 
}
}
Patico
2
You should get a reference to Camera’s game object, and then use GetComponent() method to get acces to Run class;
For example:
GameObject.Find("MySuperCameraName").GetComponent<Run>().INCREMENT_TAP++;
But it’s good practice to add some checks if MySuperCameraName object or Run component are not found.
GameObject camera = GameObject.Find("MySuperCameraName")
if(camera != null)
{
Run run = camera.GetComponent<Run>();
if(run != null)
{
run.INCREMENT_TAP++;
}
}
Now you are my friend
Thanks :mrgreen: