public void OnCheckRayCast() { RaycastHit2D hit = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { GameObject hitGO = hit.transform.gameObject; if (hitGO.tag == "MapTile") { originTile = hitGO.GetComponent <TileLogic>(); if (originTile.resource == null) { if (resourceSelected != null) { originTile.OnApplyResource(resourceSelected); } } else { SetNaturalResource(originTile.resource); } } } else { SetNaturalResource(null); } }