Search Unity

Question Setting local position not doing as expected.

Discussion in 'UGUI & TextMesh Pro' started by AimeryCM, Jun 18, 2020.

  1. AimeryCM

    AimeryCM

    Joined:
    Sep 21, 2019
    Posts:
    1
    Currently am setting up an inventory UI by instantiating a bunch of prefab inventory slots and setting their localposition to what I want. But, in practice, the positions of the instantiated objects are not what is expected. I Debug.Log'd out the localposition and normal position and the local position printed is what is expected but does not align with what is displayed in game or in the inspector mid-game. Any help would be greatly appreciated.

    This is what prints when I the following executes after all the rest of my code to generate and set the local position has already executed.
    Code (CSharp):
    1.  
    2.                 Debug.Log("Local Position: " + inventorySlots[slotNum].transform.localPosition + " Normal Position: " + inventorySlots[slotNum].transform.position);
    upload_2020-6-17_20-41-12.png

    Then in the inspector the position is
    upload_2020-6-17_20-43-1.png

    The X position is 500 units more than the local position and the Y is 250 units less than the local position. While I could just add those values, it would make the UI only look correct at this scale. Please let me know if any other information is needed.