UI element RectTransform WorldToScreenPoint issue

How do I get the screen point of a RectTransform?

I’ve tried this →

camera.WorldToScreenPoint(transform.position);

the “transform” belongs to the object that has a RectTransform. The supplied point is always a bit off, the offset amount depends on the screen size, the larger the screen size, the more of an offset there is. The canvas is set to World Space.

Thanks for any help.

Have you tried GetComponent RectTransform? Many position options!

Thank you for your reply. I am using this →

camera.WorldToScreenPoint(gameObject.GetComponent<RectTransform>().position);

And still the screen position is off.