Unity just decided to randomly change my Prefabs and GOs GUID, because why not ...

Edit : July 20 2023

2022.3.5f1 is available on Hub.

Edit : July 5 2023

Last new on this bug : Unity just decided to randomly change my Prefabs and GOs GUID, because why not ... - Unity Engine - Unity Discussions

This seems to be fixed on 2022.3.5f1 (which seems to be not yet available on Unity Hub). So far I was not able to repro this bug on 2022.3.4f1.

Original post

Hi,

I’m currently running into a bug or an undocumented change. I’m working on a project that was on 2021.3 and updated it to 2022.2.12. I did the update 2 days ago and so far everything was good, but just now Unity decided it was a good thing to just change most of the GUID of my prefabs and GameObject when I save …

This break references all over the place, because these changes are not propagated everywhere, because it would be too easy.

Here the kind of change Unity does, from the diff view of my Git client :

8926274--1223165--upload_2023-4-4_14-34-21.png
This is inside a prefab here, so components inside are correctly referenced. But if a scene or another prefab reference this one, the reference breaks …

Was there any change on the GUID format since 2021 ?

I’m getting very tired of working with Unity …

8926274--1223165--upload_2023-4-4_14-34-21.png

5 Likes

Since you’re one of the smart few using source control (AWESOME!), just roll back.

But there is USING source control and there is CORRECTLY using source control. See bottom below.

It looks more like some failure to write / serialize the file properly. GUIDs are still same-same.

That sounds like a non-LTS bleeding edge build of Unity.

Anytime you go beyond LTS you are an unpaid test pilot.

https://discussions.unity.com/t/909358/4

Here’s more random reading:

Lost progress / project / work / stuff disappeared in Unity.

This article is to help you when you have lost significant progress or work in your Unity project.

It is designed to give you avenues of discovery and investigation.

It is NOT a guarantee of restoring your lost work. It is NOT a substitute for proper IT / Data security procedures.

To decide which parts are applicable to you, look for major bolded headings.

EVERYTHING IS GONE, YOU CANNOT OPEN THE PROJECT

Your project probably is still on your computer. Try a computer-wide search for some unique filenames that you know are in the project you think is gone.

To start your search, one common file to all Unity projects is named ProjectSettings.asset

Some things that might have happened:

  • you are not opening the project that you think you are
  • you are in the correct project but not opening the same scene you had open before
  • you dragged the project (or part of it) into the trash (intentionally or inadvertently)
  • you moved the project (or part of it) somewhere else (intentionally or inadvertently)
  • an overly-aggressive antivirus solution quarantined it because it saw code being compiled in there
  • you’re using a directory sync like OneDrive or Dropbox… NEVER USE THESE SERVICES WITH UNITY!
  • something else??

As I said, it’s probably still all on your system to be found if you look in the right places.

A typical Unity project will have at a minimum the following folders:

ProjectSettings\
Packages\```

**EVERYTHING IS PRESENT BUT MY SCENE WINDOW IS BLANK**

Close Unity and make a full project backup RIGHT NOW. Do not do ANYTHING else until you back it up 100%.

Ideally copy that backup to another computer, or back it up to another external hard drive entirely. This is just basic data processing best practices during data recovery operations.

If you can see all the files and folders of your project, make sure you are opening the scene file you were working in.

Once you have opened the scene, look in the hierarchy window, select an object and move the mouse over the Scene window and press F to focus that object.

Additional notes:

- ALWAYS use proper industrial grade source control (see below)
- NEVER use Dropbox or any file sync mechanism in Unity.
- NEVER move files within your project, except by doing it within Unity
- ALWAYS be sure you are fully backed up before upgrading Unity

**SCRIPTS OR ASSETS ARE MISSING OR BLANK**

Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

https://discussions.unity.com/t/836322/2
https://discussions.unity.com/t/815173/7
https://discussions.unity.com/t/815173/9

EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

**When Renaming**: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don't do that. Instead:

- close Visual Studio (important!)
- rename the file(s) in Unity
- in Unity do Assets -> Open C# Project to reopen Visual Studio
- now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

**UNITY CRASHES / FREEZES WHEN I OPEN MY PROJECT**

You must isolate if there is something wrong with your Unity installation, something wrong with your project, or perhaps just a corrupted import or asset database.

First, ALWAYS back your project up. Then try deleting the ```Library/``` and ```Temp/``` folders that are within your project, the directories that are peers to the ```Assets``` and ```ProjectSettings``` folders.

If that doesn't work it is time to bisect. Make a new empty project and get Unity to open that. If you cannot then it is time to fix your Unity installation, either by fully reinstalling or verifying it with the hub.

Once you have an empty project open, begin copying over your project. Try the entire thing. If it crashes, try half of the project, then the other half, etc.

As always, if you're using Windows, another "first thing to try" is to simply reboot the system. This often fixes typical Windows issues related to locked files and locked directories.

**ISSUES RELATED TO UPGRADING PROJECTS (eg, changing to a higher Unity version)**

Upgrading to a later version of Unity is a one-way process. Any project that has been updated should NEVER be reverted to an earlier version of Unity because this is expressly not supported by Unity. Doing so exposes your project to internal inconsistencies and breakage that may actually be impossible to repair.

If you want to upgrade to a newer version of Unity, do not even consider it until you have placed your project fully under proper source control. This goes double or triple for non-LTS (Tech Stream) versions of Unity3D, which can be extremely unstable compared with LTS.

Once you have source-controlled your project then you may attempt a Unity upgrade. Immediately after any attempted upgrade you should try to view as much of your project as possible, with a mind to looking for broken animations or materials or any other scripting errors or runtime issues.

After an upgrade you should ALWAYS build to all targets you contemplate supporting: iOS and Android can be particularly finicky, and of course any third party libraries you use must also "play nice" with the new version of Unity. Since you didn't write the third party library, it is up to you to vet it against the new version to make sure it still works.

If there are issues in your testing after upgrading Unity, ABANDON the upgrade, revert your project in source control and be back where you were pre-upgrade with the earlier version of Unity.

Obviously the less you test after the upgrade the more chance you will have of an undiscovered critical issue.

This risk of upgrading is entirely on you and must be considered whenever you contemplate a Unity version upgrade.

Do not upgrade "just for fun" or you may become very unhappy.

**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://discussions.unity.com/t/736093/3

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://discussions.unity.com/t/807568/3

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

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

Generally setting Unity up (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

I can second that this happens in our project in Unity 2022.2.18. I’m not sure how to reproduce it, but it’s really annoying.

Same problem here, thanks to Source Control I saw the problem and I was able to rollback, but I could have done a commit thinking it was not an issue at all.

Very disturbing bug…

It has started to happens to me with Unity 2022.2.20… I have been working with Unity 2022.2 versions from the beginning without issues (4-5 months ago).

Has been this bug reported or is it a known issue???

It is a very serious bug, because it breaks the project in a silent way, and if you don’t notice it, you’ll start to see things working in a weird way.

2 Likes

Please create a bug report and attach the Prefab files where you see this happening. And the Unity versions used.
Looking at the fileIDs in the first screenshot it looks like the Prefab comes from an AssetBundle? (due to the low fileIDs numbers), is that the case?
We want to look into this ASAP but cannot repro on our side currently.

Also any information if this issue occurs after building a player or assetbundles would be useful.

@Mads-Nyholm , so far, I’ve consistently been able to reproduce this issue in my current state.

Whenever I build a new IL2CPP Windows version in Unity 2022.2.20, I notice that certain prefabs are automatically modified. This results in changes to the GUIDs and inadvertently breaks several elements of my game.

I did a bug report some days ago (CASE IN-41717), but I was not being able to reproduce it always.

But now it is happening always I build the game, so I have opened a new bug report (CASE IN-41896).

Thanks @Tornar ! This is helpful. I will take a look first thing tomorrow.

@Tornar thanks for the repro project it has helped us to repro the issue and we are now working on a fix.

We now have a fix going into the next build for 2022.2.
Thank you to @BSimonSweet for bringing it to our attention and to @Tornar for the repro project.

The issue was related to a package that called AssetDatabase.SaveAssets() during a build postprocess callback. This will be disallowed in the future.

2 Likes

Wow! That’s such wonderful news!

This bug was a real nightmare.

Thank you so much for the swift solution, @Mads-Nyholm .

Great ! Thanks for your work on that fix. My tone was a bit sarcastic and annoyed in my first post, sorry for that, but it was driving me crazy … I’m glad to see it wouldn’t happens anymore, hopefully !

Incredible news.

@Mads-Nyholm what Unity version has the bug fixed?

I am using 2022.3.0 LTS, and I have been able to do 2-3 builds without issues, but now I have done a build, and I’ve got the same problem.

@Tornar It landed in 2022.3 LTS (it was an issue with URP), so it sounds like other packages/systems are causing this as well.
Does this happen with the same repro project as you sent in earlier? Please provide all the info you have about this issue as it currently happens. Thanks

Yes @Mads-Nyholm It happens with the same repro project I sent.

It happens randomly when building Windows version (IL2CPP).

But it is very weird, because now it’s happening, sometimes, even when closing Unity Editor.

Ok, will take a closer look at what is included in your project that can cause this.

@Mads-Nyholm have you been able to repro it?

It is happening to me when I do the following steps:

  1. Build a new version (no problems, Unity Version Control doesn’t show up prefabs changes)
  2. Build a new version over same directory than before (no problems, Unity Version Control doesn’t show up prefabs changes)
  3. Close Unity Editor (Unity Version Control show prefabs GUIDs changes)

I hope it helps to you to repro the bug.

By the way, it started to happens with Unity 2022.2.19 or 2022.2.20 (no sure what version, some weeks I don’t need to do a build), but I’m sure that it was not happening in first 2022.2 versions.

1 Like

Hi, having the same kind of problem: 2022.3.1 LTS:
“Repro”:
SO that refs a Prefab
Edit the Prefab: like add stuff to it then save it then remove the stuff then save
→ SO lost the ref to the prebab
Looks like all the UIDs in the prefab changed (when comparing with prev version of the prebab)
(Also happens in PrebabA to PrebabB ref when PrebabB is modified (in this case the code of it).
(Looks like it is the FileID of the prebab that got changed)

This is really stressfull. !
Thanks teram!

1 Like