I’ve got a Canvas
.
I’m creating some Text
elements right above 3D objects in the scene with this code:
Vector3 screenPos = Camera.main.WorldToScreenPoint(this.dices[x, z].transform.position);
screenPos.x -= 25;
screenPos.y += 10;
newScoreItem.GetComponent<RectTransform>().anchoredPosition = screenPos;
On Android my UI elements are tiny so I set the surrounding Canvas` UI Scale Mode to “Scale with screen size”.
The problem is that the position I determine with the code above doesn’t match the one of scaled canvas. My Text
elements are scaled but at the completely wrong location.
How may I solve that problem?