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

Bug positions keep resetting incorrectly

Discussion in 'Editor & General Support' started by patrickjansendesign, Jul 20, 2023.

  1. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
    I opened a project in a newer Unity version after buying a new pc but a few UI game objects had incorrect positions. I corrected them, but, every time I save the project, close it, and reopen it, they go back to incorrect positions. Also, If after opening i go from one scene to another scene and back to the original they're suddenly correct again. But when I publish the project and test on my phone they're incorrect.

    what is happening? how do i fix this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    What positions on what items? UI items?

    Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:

    https://forum.unity.com/threads/inc...size-between-two-people.1130146/#post-7261747

    https://forum.unity.com/threads/game-ui-button-size-problem.1142650/#post-7337383

    Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.

    I also use this
    CanvasScalerOrientationDriver
    utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.

    https://gist.github.com/kurtdekker/8802b1b6c708637398f8c9167641efd3

    Otherwise...

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)
     
  3. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
    it's not a matter of finetuning or anchoring. For example, some button in my original project on old pc was placed at X,Y 150, 150. For some reason on my new pc in new unity version it opens the same project with button on X,Y 0, 35. When I place it back to 150, 150 and save the project, close it, reopen it, it's back at X,Y 0, 35.

    When i open another scene and then open the first scene again... it IS correctly at 150, 150 but if i publish it and try on phone it is at 0, 35

    It only happens with about 4 or 5 buttons but I still need to fix them.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    What you describe is exactly what happens when there IS an anchoring / scaling problem.

    What leads you to conclude that your project is different?

    Great, get started on the anchoring and scaling notes above.

    Hint: that's how you fix this stuff.
     
  5. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
    It isn't
    I actually narrowed down the problem. Above i gave example positions but the positions were just to give an example. It's actually ONLY the Y value which resets.

    Plus I tried something else
    - i created a new canvas with anchoring as described in first link you gave (my ui's already have the same anyway)
    - i created a new image
    - i anchored it left top
    - i place it at XY 33,33
    - save the scene, save the project
    - close it, reopen it
    - image is at position XY 33,0
     
  6. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
    Followup -> if i create an extra blank GameObject next to the image and anchor it left top, and then place the image in that gameobject, save project, close, and reopen, the image DOES reopen at 33,33

    it really feels like a bug.
     
  7. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    159
    Which Unity version are you using? There was a problem with UI in v2022.3.* that's fixed in v2022.3.5, so try that version
     
  8. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
  9. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    159
    Yes, that’s the buggy one
     
  10. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    45
    now my dilemma, either place a container gameobject around/above my buttons and fix it that way or install new version and risk jdk gradle trouble again like I had trying to get my project working from old to new pc.