void Update() { mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { Vector2 reach = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y); if (reach.magnitude < maxReachDistance) { var go = tilemap.GetTileGameObject(mousePos.x, mousePos.y); go.GetComponent <Renderer>().material.color = Color.grey; go.GetComponent <Collider2D>().enabled = true; } } if (Input.GetMouseButton(1)) { Vector2 reach = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y); if (reach.magnitude < maxReachDistance) { var go = tilemap.GetTileGameObject(mousePos.x, mousePos.y); var tile = tilemap.GetTile(mousePos.x, mousePos.y); go.GetComponent <Renderer>().material.color = perlinGenerator.BiomeToColor(tile); go.GetComponent <Collider2D>().enabled = false; } } }