yesterday my game was working 100%. No issues.
Today I open Unity and my game is broken!
Unity claims 2 missing scripts on many prefabs. Yesterday they were there.
The root prefab shows the script’s name but the script component has the name “Script” instead of the scripts name, see attached file “root prefab”.
When I click on the scripts name, the project view jumps to the script. It is there and Unity knows it???
In prefab variants the scripts are claimed to be missing, although they are clearly not! , see attached file “prefab variant”.
There are no compile errors.
Reinstalling the package those scripts are from doesn’t change anything. That makes sense to me because the package was not updated. I know this since it is my own git package.
Restarting Unity also doesnt help.
I did get a blue screen while opening my Unity project this morning. After restarting the PC Unity opened as usual but now claims these missing scripts that are clearly there.
nothing that makes sense to me. The only thing that seems to have changes is “PackageManagerSetting.asset”.
I already reset to yesterday’s last commit. nothing changes. That makes perfect sense, since nothing has changed.
If anything changed on the Unity file structure it is outside of my version control. So maybe in the git exclusion file
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Recordings can get excessive in size
/[Rr]ecordings/
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
*.app
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
/Assets/zzz_UnityAssetPacks/
/Packages/com.singularitygroup.hotreload/
I did however get a blue screen when opening my project this morning. After a reboot it opened, but now claims these missing files.
When trying to add the same scripts to a new prefab I get an error stating “Can’t add script component ‘ProjectileWeapon’ because the script class cannot be found. Make sure there are no compile errors and the file name and class name match.”
Both is the case. There are no compile errors and file & class name are the same
Try deleting the Library folder with the project closed. Possibly some stale or corrupt cache data, especially after a bluescreen.
If you happen to see bluescreens more than once per week (or even per month depending on how intensive you use the PC), you should definitely update drivers and perform a hardware check, preferably with some intense check tool that boots off of a stick or floppy.
oh dude THANK YOU!
Deleting the library folder fixed it. The blue screen was surprising to me, it’s not normal for me to get one. Not sure what happened there. But the main thing is that my Unity project is not screwed up.
I do not think that “deleting the library” is a good answer given how it can trash the project on some systems at least when using some versions of Unity.
Closed project.
Copied project to make backup.
Deleted library folder (and only it).
Restarted project.
Everything was wiped out - all the setups etc. Project opened blank with the camera and nothing else left.
Exited project.
Cleaned everything out of library.
Copied everything from the backup copy’s library.
Restarted project.
Everything is back and functional.
REPEAT: I do not think that “deleting the library” is a good answer given how it can trash the project on some systems at least when using some versions of Unity.
It’s just cached data. Unity projects don’t depend on anything inside the Library folder.
What MAY happen is that user deletes that Library folder while the project is still open, or in the process of shutting down, or the project is opened again while deletion is still in progress (it takes a while due to many small files). This can cause issues but properly deleting the Library again will fix these.
Then you deleted more than just the Library folder, or one of the above happened, or you had an error in your assets that surfaced only after Unity was forced to re-import that asset. Check the console for any errors.
If you can reproduce this, make a video as proof. There has not been a single credible report about what you said. Just saying “some systems, some versions” makes it sound like spreading FUD.
I did it again. I have no video recording software. Exited the project. Deleted the library file. Reentered the project. It came up blank.
Now, what someone trying to be helpful (and who has experience with such things and is not slinging FUD) might have pointed out was that IT WAS BLANK BECAUSE IT DROPPED THE SCENE out of the hierarchy. I am new to Unity and only recently learned how to switch scenes and so on. I COPIED THE SCENE (the only scene scene I had) from assets to the Hierarchy and it all came back.
So, no, it did not wipe everything out, I just did not know what was going on. And had to figure out what was in the long term a very simple fix all by myself.
So, excuse me for not being a genius and just being a novice.
And when the project opened, did you navigate to the scene and open it?
I think deleting the Library also „forgets“ the most recently opened scene (and possibly other „most recent“ states).
The scene likely still exists and is fine, it just won‘t open by default but rather have some „Untitled“ or „SampleScene“ loaded initially.