The question is answered, right answer was accepted
World to screen point wrong.
Hello,
I have made a blank project with a fresh canvas and added an image to the canvas. I have also added a cube to the scene.
I am using the following code
public RectTransform Image;
public GameObject Object;
public Camera Cam;
void Start()
{
var position = Cam.WorldToScreenPoint(Object.transform.position);
Image.anchoredPosition = position;
Debug.Log(position);
}
The image on the canvas goes to the top right of the canvas, no where near my cube. What have i done wrong?
Are you sure the anchors of your image are on the bottom left corner of the canvas? The origin of the screen coordinate system is on the bottom-left corner of the screen while the default origin of a UI element is in the center of its parent.
Follow this Question
Related Questions
Unity splash screen outline visible 0 Answers
Auto resize/rescale ongui 0 Answers
How to change resolution? 0 Answers
Android Build Bug 0 Answers
How to delete ScreenManager PlayerPrefs? 0 Answers