Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Get position of RectTransform in layout group

Discussion in 'UGUI & TextMesh Pro' started by theBdrive, Jun 26, 2020.

  1. theBdrive

    theBdrive

    Joined:
    May 22, 2015
    Posts:
    20
    I have a canvas set to screen space overlay with a responsive layout using layout groups. Im trying to apply a tween to move the element 100 pixels from its current location. In the past with UI elements not in layout groups if I wanted to say move the current RectTransform 100px from its current position using DOTween I could just reference the current transform like

    Code (CSharp):
    1. RectTransform.DOAnchorPosY(transform.position.y + 100, 0.5f);
    Seems I can't reference the transform.position on a RectTransform if it is a layout group because of the anchoring driven by its parent with the layout group. How can I get the RectTransform current position when it's in a layout group?
     
  2. Aykutkaraca

    Aykutkaraca

    Joined:
    Jan 4, 2018
    Posts:
    33
    Last edited: Oct 19, 2020