skip to Main Content

Custom APIs for dealing with UI and GameObject interactions

X-Frame provides a set of useful APIs to adjust the tap or mouse positions due to downscaling:

To access the API use this code:

using XFrameEffect;
XFrameManager xframe = XFrameManager.instance;

Then the following methods are available:

public void UpdateUICanvases()

Call only if you create Canvas objects at runtime. This method will force X-Frame to integrate with new canvas UI objects.

public Vector3 AdjustScreenPosition(Vector3 position, bool targetIsDownscaled)

Transforms the input position into a proper screen coordinate that takes into account downsampling. If the target position is aimed to a screen space overlay canvas, set targetIsDownscaled to false.

public Ray ScreenPointToRay(Camera camera, Vector3 position);

Returns a Ray object from a camera and a screen position.

public RaycastResult Raycast(Camera camera, Vector3 pointerPosition)

Performs a raycast on the camera from the pointer position (ie. screen mouse position or Input.mousePosition)

public bool IsPointerOverUIElement(Vector3 pointerPosition)

Returns true if the pointer is over any UI element of any Canvas (only canvas set to Screen Space – Camera or World Space).

public bool IsPointerOverGameObject(Camera camera, Vector3 pointerPosition)

Returns true if the pointer is over any gameobject.

Back To Top