When working on a Unity3d project with a team, no matter how meticulously you keep track of your meta files, the occasional missing file/shader/material will happen.
The problem happens when someone forgets to commit a meta file, but does commit the file it belonged to.
For example one commits
<some_material>.mat but not its
When others pull down the changes they'll get the file, but not the meta-file.
In that case Unity will create a new meta file with a different GUID, so it won't recognise the material file as the same file across the different workspaces anymore.
When it happens sometimes a console warning similar to this will be shown:
The GUID for Assets/Resources/Materials/<some_material>.mat is already in use by Assets/Resources/Materials/<some_material>1.mat. Assigning a new guid.
But I find that it's easy enough to overlook that warning if you're not keeping an eye on the console.
One console clean and it's gone forever.
The most annoying symptom of mismatching GUIDs between workspaces is when a reference to the file is put in a scene. When opening that scene from the other workspace (with the different guid) the reference will be missing, even though the file it refers to is actually in the project, which can be quite puzzling.
In particularly stubborn cases it's not enough to make sure the GUID matches, because the Library will retain the error.
Assuming you have a reference workspace where you're going to correct the error and then push to version control, the solution then is:
- close unity on reference workspace
- delete broken meta files
- delete library
- open unity
- wait while the library is re-created
- make sure to add the meta files to version control
- put the right reference in the scenes again (eg. material on a renderer)
- commit new meta files and changed scenes
- close unity on the machines receiving changes
- delete library on those machines
- get latest version from version control
- reopen unity
- wait for library to be remade
That should do it.