Cell size to Canvas size

Hi,
I want a panel (inside my Canvas) to be at a given tile position.

Let’s say i have my tile at position (1, 2, 0) on my tilemap, I transform this pos to world:

var cellWorldPos = Tilemap.CellToWorld(tilePos); // -> (1.0, 2.0, -1.0)

Then I transform it to Viewport pos:

var cellViewportPos = cam.WorldToViewportPoint(cellWorldPos); // -> (0.6, 0.7, 999.0)

And I set my panel pos:

ConfirmBox.transform.position = new Vector3(cellViewportPos.x, cellViewportPos.y, ConfirmBox.transform.position.z);

First problem: my panel is now at pos (-591.4493, -332.3198, 0) (not tile pos).

Second problem: if , instead I set the pos the panel’s local pos (so (0.6, 0.7, 0)), it isn’t at the tile pos either.

First case when setting to panel’s world pos (the green square is the tile, the green check symbol is a part of the panel).


Second case when setting to panel’s local pos.

I found the answer, indeed i must use ConfirmBox.transform.position = cam.WorldToScreenPoint(tilePos) ! I thought I already tried that but it seems that I’m wrong. :confused:

Anyway, resolved.