Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Transform is getting weird result

Discussion in '2D' started by toblex, Oct 11, 2020.

  1. toblex

    toblex

    Joined:
    Aug 22, 2017
    Posts:
    2
    Hi,
    I have a transform position that I want to copy and adjust. If I copy the position it works fine, however after some testing i'm getting some very strange results.

    e.g
    List<RectTransforms> transtest

    transtest[0].position = flanguage.transform.position;
    this works fine and I get a position that matches that of the flanguage position (0,0,0.

    However if I add the following:
    transtest[0].position = new Vector3(flanguage.transform.position.x + 1f, flanguage.transform.position.y, flanguage.transform.position.z);

    or

    transtest[0].position = new Vector3(flanguage.transform.position.x - 1f, flanguage.transform.position.y, flanguage.transform.position.z);

    I get the y and z that match flanguage z and y position but the x position becomes (-3.21,0,0) for both those lines of code.

    Can anyone suggest what error is occuring?

    Cheers.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,349
    @toblex

    You are asking UI question in 2D forum.

    Also, it is pretty hard to follow what you are doing... maybe add more explanation, images of setup, inspector and what you are actually trying to achieve.

    UI issues are heavily related to Canvas type, Canvas Scaler settings and anchors and so on...

    So it is pretty hard to say much.
     
unityunity