Recently, while working on one of my projects in Unity, I opened one of my C# scripts, and… my Unity Editor decided to get itself stuck on the loading screen for a really long time. This led me to search online for a fix, and it took me quite some time.
If you’re experiencing the same issue, this article is for you. Hopefully, you won’t take as much time as I did to fix this error.
Here are some possible causes for your Unity Editor getting stuck on the loading screen:
- Your Library folder has very large files
- Check if the project folder is stored in OneDrive
- Uninstall the .NET Core SDK
1. Your Library folder has very large files
A Unity project that you open from the Unity Hub is actually just a collection of files and folders. The Library folder is one of these folders, and it primarily serves as a cache that helps to speed up the loading of your project over multiple uses.
Fun fact: If you’ve got your projects hosted on Plastic SCM, or if you follow our guide to host your Unity projects on GitHub Desktop, you will notice that the Library folder is also excluded from being uploaded onto the project repository. This is because, being a cache, Unity will automatically regenerate it when you load the files on a different computer. Hence, there is no point in uploading the Library folder, as it does not help to speed up loading times for other users.
For various reasons, files in your Library folder may have become bloated (i.e. extremely large in size). This may be causing Unity to crash when you try to open a C# script.
a. Finding your project folder
To fix this issue, you will need to first find and open the project folder of your Unity project. There are a couple of ways to do this, but the easiest way is to right-click on your Project window and click on Open in Explorer (or Open in Finder for macOS users).
b. Searching for large files
Once in there, head into the Library folder, then search for and delete for files that are extremely large, i.e. anything over a gigabyte (GB).
A file that frequently has a large file size in Unity projects is the
ShaderCache.db file, so that is one of the first few files you want to check.
Article continues after the advertisement:
c. Using a search filter to find large files (Windows)
An easy way to filter your Library folder for large files on Windows is to go to your search panel on the top-right corner (from your Library folder), then type in
size:gigantic. This will find you all files that are above 128 megabytes (MB) in the folder.
If you can’t see file sizes in your Windows Explorer, you can have a look at this article on how to turn on the file size column in your Windows explorer.
d. Using a search filter to find files by file size (macOS)
If you’re on a macOS, you can also filter files in your Library folder by file size, but the process is a little different. Once you’re in your Library folder on Finder:
- Activate search by pressing ⌘ + F.
- After the
Search:label, select the
- On the dropdown, select File Size and type in the size of the file you want to find.
e. Deleting the whole Library folder
If you want to skip the entire process of finding these files, you may also delete the entire Library folder, but Unity may take a long time to regenerate the Library folder the next time you use the Unity Editor.
This should solve the problem. If not, or if you can’t find any large files, proceed to the next solution.
2. Check if the project folder is stored in OneDrive
OneDrive (for Windows) can cause issues with Unity projects. To check if your project folder is stored in OneDrive, open your project folder in the File Explorer. Folders managed by OneDrive have a “status” column, as seen below:
If your project folder is managed by OneDrive, simply move it out of OneDrive or disable OneDrive. This should resolve the issue.
It may be worth noting that other cloud storage services such as Google Drive may also cause the same issue so you may want to check for other cloud storage services that may affect your project folder.
If your issue is not resolved after this, another thing you can try is to…
3. Uninstall the .NET Core SDK
The cause of the issue could be due to certain SDK versions. The issue may be resolved after you uninstall the .NET Core SDK by following this guide.
If this solution does not work, or if you encounter problems with Visual Studio after this, you can try running the Repair option in the Visual Studio Installer to get things back to normal. To do this (on Windows):
- Go to Start and search for
visual studio installer. You should find an app called Visual Studio Installer.
- Click on the More button, then click on Repair. After that, follow through with the process.
I hope that this article has helped you in some way. Although it seems simple, this issue can be frustrating to solve. If none of the solutions worked for you, it will be great if you can leave us a comment to tell us how you fixed it.
If I have missed anything in this article, or if you have found other solutions you would like to share for people running into the same issue, please leave us a comment below too, as it may help others with the same problem as well!
Article continues after the advertisement:
There is one comment:
thanks this was giving me a headache today, after searching for ages i found your post cheers. It was the onedrive setting i had changed causing my unity to crash