Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug UI Elements in one canvas all moved - project not saving changes

Discussion in 'Editor & General Support' started by NotMyUsernameAgain, Jul 31, 2023.

  1. NotMyUsernameAgain

    NotMyUsernameAgain

    Joined:
    Sep 28, 2017
    Posts:
    142
    Hi everyone,
    using Unity ver 2022.3.4f1.

    So I was working the whole day on my project as usual, so while in text play I opened my main menu and for some reason all the GameObjects are placed differently where they used to be.

    I was NOT working on that canvas at all today, most of them are no prefabs, and I'm facing this problem the first time.

    So I moved a few back to the correct position, saved and restarted Unity, and the GameObjects are back to the wrong position?

    I can't restart my PC right now, but does anyone know anything about this?

    Also, does Unity make backups? To be honest, I don't really want to rearrange all my GameObjects back to the proper positions again.

    Thanks in advance

    EDIT: Luckily I still had a manual backup, so I'm copying these values one by one now.
    Apperaently the Pos Y has been changed to 0 at several GameObjects.
    Even if I did by accident I don't know how, because these are very nested GameObjects, but not all has been set to 0, so I don't think I marked them accidentaly.
     
    Last edited: Jul 31, 2023
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    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

    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally the ONLY folders you should ever source control are:

    Assets/
    ProjectSettings/
    Packages/

    NEVER source control Library/ or Temp/ or Logs/
    NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

    Setting git up with Unity (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  3. NotMyUsernameAgain

    NotMyUsernameAgain

    Joined:
    Sep 28, 2017
    Posts:
    142
    Always thankful for your answer
    I'm always using a CanvasScaler 1920:1080 with "Match Width or Height" set to 0.5.

    I was actually only doing scripting the whole day, and then at one test play it suddenly appeared that way.
    Well nvm, I'm going to rearrange them all by copying the values from my backup.

    Also thanks for the info for "backup".
    I'll look into it if I find some time, but for now I'm good with doing manually backups time by time.
     
  4. matios-free

    matios-free

    Joined:
    Jul 17, 2022
    Posts:
    2
    Hey there. Same happens to me in Unity 2022.3.4f
    I did some work around and noticed, if after openening your project you see that your objects are not on the right places, just open another scene and then go back to the previous one, all will be fine. No need to revert positions manually.
     
    dark31521 likes this.