Hello everyone!
It looks like I just made one dumb mistake but heres the code that stands in 2 c# scripts but is working in only 1 script:
if(Input.GetMouseButtonUp(0)){
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Collider2D hitCollider = Physics2D.OverlapPoint(mousePos);
if(hitCollider){
if(hitCollider.name.Contains("menu")){
print ("I have just clicked a part of the menu!");
}
print (hitCollider.name);
}
else{
print ("not detected any colliders :(");
}
}
The result in the first script is that it prints the name of the clicked collider whilst in the other script the result is that it prints “not detected any collider”.
Note: maybe it is important to know that these two scripts are in two different unity projects.
And I didnt forget to add a 2d collider! ![]()
thank you for even reading my question.
Any help is appreciated!