hi all,
while working on my project midway through a script i got 120 errors saying everything already had a global name space. somehow all of my scripts got duplicated. afterwhich none of my prefabs would work since the scripts had been messed with and couldnt figure out what was what. im not sure why the default material changed to magenta.
i have to redo everything and cant seem to find a fix for this. thankfully im not super far into things and this could have been a bigger disaster than it currently is.
does anyone know what causes or what a fix for it would be if it happened again? I’m in the process of rebuilding but it would be good to know. the last thing i did was create a new scene and script which did nothing at the time.
I’m afraid that without steps to reproduction we can’t be much of help.
But at least I can tell you that your .meta files are messed up. Meta files are important because they contain the identity of your assets (whatever inside the Assets folder). This identity makes it possible to attach any component to a GameObject.
Also, if an asset doesn’t have an accompanying meta file, Unity will generate a new one for it - with a new identity (GUID).
Because of whatever mistake has happened, your scripts have lost their old meta file, thus lost their identity, so Unity has to generate new one for them. Consequentially, components already attached to that GameObject are now unrecognizable because of the identity mismatch.
This indicates that the shaders are incompatible with the current rendering pipeline configured for your project. Your project and shaders must be of the same rendering pipeline, either BiRP or URP, not mixed.
It’s possible that when you redid things, you’ve also changed the rendering pipeline configuration.
On a footnote, I seriously suggest you to try using a version control system, such as Git. It can help you identify what has gone wrong compared to the last change. You can also revert the whole project back to the past with a great confidence.
Something like this doesn’t just randomly happen. Catastrophic failures like these are almost certainly caused by using Unity incorrectly or by manipulating the project in unsupported ways.
This can range from manually moving, renaming, deleting, modifying asset files via Explorer/Finder. Using source control incorrectly, eg excluding .meta files or not excluding the /Library folder. Having the project on a cloud-synched folder/drive will almost inevitably cause project corruption! Or an editor script that manipulates asset files went haywire. Or running a “cleaning tool” that removes “duplicate files”, as one user once did. Very rarely antivirus might also interfere, though most commonly it’ll mess up installing or launching Unity, or making and running builds (I’ve not heard AV corrupting a project .. yet).
Deleting the /Library folder (with project closed) would be the first troubleshooting step if something inexplicable like this happens.