Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to get real position of UI element on canvas

Discussion in 'UGUI & TextMesh Pro' started by LoopIssuer, Dec 12, 2022.

  1. LoopIssuer

    LoopIssuer

    Joined:
    Jan 27, 2020
    Posts:
    109
    Hi,
    How to get the position of UI element on the canvas. In the attached picture I have a canvas (screen) with a height = 1920. Position.y is shown 500 (it is relative to anchors). 'Real' position.y is about 1690 (from the bottom of the screen).
    When I change the canvas (screen) size, the 'real' position will change too.
    In addition - the white image is not directly under canvas - it has lot of parents in the hierarchy.
    How to get this position in code?

    Thanks in advance for the help.
    upload_2022-12-12_20-48-41.png