Scene |
public Vector2 Point3DTo2D( Vector3 point3D, bool adjustByDpiScale = false )
Point3DTo2D converts a world space 3D position (as Vector3) to the 2D screen position (as Vector2). To calculate the 2D position for the final UI element, set the adjustByDpiScale to true otherwise the 2D positions will be positioned inside the view defined by SceneView's Width and Height.
The matrix to convert 3D point to 2D point is calculated from the used Camera. The matrix value is cached and is only recalculated when the camera is changed or when the size of the view is changed.
If the matrix to convert 3D point to 2D point cannot be calculated (for example if the size of this SceneView is not set), the returned point will be Vector2(float.NaN, float.NaN). To check if the conversion can be done you can call CanConvertPoint3DTo2D method before calling this method.
To convert multiple 3D points, use the Points3DTo2D(Vector3, Vector2, Transform, Boolean, Boolean) method.
To use Point3DTo2D method without creating the SceneView, then you can use the static Point3DTo2D(Vector3, Camera, Single, Single) or Points3DTo2D(Vector3, Vector2, Camera, Single, Single, Transform, Boolean, Boolean).