I am trying to click on one of the bottoms of a menu, but the collider is null inside the Physics2D.Raycast when I check it out.
That is the code:
Code (CSharp):
- void Update()
- {
- ray = Camera.main.ScreenToWorldPoint( Input.mousePosition );
- hit = Physics2D.Raycast( ray, Vector2.zero );
-
- if( Input.GetMouseButtonDown( 0 ) )
- {
- Debug.Log( hit.collider != null );
-
- if( hit.collider != null )
- {
- createTower( hit.transform.name, hit.transform.position );
- }
- }
- }
I have noticed when I click on the object that will show the menu it is working, but when the menu shows up and I click on one of the options, nothing happens. All options are inside a game object called menu and all them have the box collider 2d.
Does someone can help me out?