OneDrive broke my Unity Project

While I was working on my project yesterday, I was suggested to use the school OneDrive so that I could access my project from any computer, but when I loaded it up on my main computer, it gave me a bunch of errors yesterday, but now only 3:

Failed to resolve packages: An error
occurred while reading the file
[C:\Users\Ja.----20\OneDrive
----------- ------ -------- --. –\Documents\Unity\Battle System Terradaro
Ideas\Packages\manifest.json]:
UNKNOWN: unknown error, read. No
packages loaded.
A re-import of the project may be required to fix the issue or
a manual modification of
C:\Users\Ja.----20\OneDrive
----------- ------ -------- --. –\Documents\Unity\Battle System Terradaro
Ideas\Packages\manifest.json file.

Assets/Scripts/LoadNewArea.cs(21,35): error CS1070: The type ‘UnityEngine.Collider2D’ has been forwarded to an assembly that is not referenced. Enable the built in package ‘Physics 2D’ in the Package Manager window to fix this error.

Assets/Scripts/MusicController.cs(8,12): error CS1070: The type ‘UnityEngine.AudioSource’ has been forwarded to an assembly that is not referenced. Enable the built in package ‘Audio’ in the Package Manager window to fix this error.

What can I do to fix these errors?

It was a simple fix, as it turns out. If this has happened to you, the solution is super easy, just create a new project the exact same way as the last one, and copy the manifest from the new one onto the old one. A.K.A. if you created a 2D project, create a new 2D project and copy that manifest.

LEARN FROM MY SUFFERING AND NEVER PUT IT IN ONEDRIVE.

i have the same issue but i fixed it by opening the project before onedrive starts syncing it

DO NOT USE CLOUD STORAGE SYNC!

At least not for the whole project. You can zip the project and move the zip to the cloud drive, then unpack on another machine.

The problem with cloud sync - no matter which cloud storage provider - is that Unity projects are not designed to work with these, and as a result they can cause project corruption beyond repair!

Here’s the problems with cloud synch of a Unity project:

  • It syncs the Library folder - aka waayyyy too much, way too often
  • It’s not guaranteed (not easy to see) that the latest version has completely uploaded
  • Same issue with downloads, you may be opening the project before it has fully synched all files
  • There is no conflict resolution - the file that was uploaded last from any machine will override any existing file. Particularly problematic if you ever have the project open on two or more machines simultaneously.

Use source control! (ie GitHub)

!! YOU DONT NEED TO CREATE A NEW PROJECT TO SOLVE ONEDRIVE ISSUES LIKE THIS !!

SOLUTION for Build Issues with Onedrive in Unity

  1. Close out Unity.
  2. Delete the Library/Bee and the LibraryBuildPlayerData in your Library folder of your project. Dont worry because Unity downloads these folders back again if they are missing.
    image
  3. Load Unity project again, and you’re set!
  4. If you still have issues building, there might be more folders your project needs to use, in that case delete the Library folder or try read the error message and see what folder its trying to access. Again don’t worry, Unity reloads these files just like when you start a new project.

SOLUTION for Asset Folders and File Issues with Onedrive in Unity (Drag and Drop Not Working)

  1. Go to Assets tab on top of Unity menu.
  2. Click “export package…” and select ALL your assets. Then choose a place to put it in.
  3. MAKE SURE YOU DO STEP 2, then delete all assets in the assets folder using file explorer or assets window if it lets you.
  4. Right click in assets window and import package and choose the package you exported. You should have all your assets back again with no issues.

For some reason Onedrive messes with the file permissions in Unity files. I still can’t figure out how or why. My guess is that Unity is reading and writing files while Onedrive is trying to sync. I believe if you pause syncing on Onedrive everytime you go on Unity, it MIGHT prevent this issue.

I spent hours trying to solve this. Hopefully, I can save someone else’s the trouble!!