- Home /
Unity + Git = Components missing files
I've never worked with git and unity before so I've read several online tutorials about the process and correct workflow.
I believe I've done everything properly yet I'm getting an annoying issue. I just cloned my private repo from bitbucket to my new laptop and any component that has files attached to it is missing those files.
Scripts - "The associated script can not be loaded."
Sprite Renderer - Missing sprites
Colliders - Missing materials
etc...
My .gitignore:
Library
Temp
*.sln
*.csproj
*.unityproj
*.pidb
*.userprefs
Edit --> Project Settings --> Editor:
Version Control: Visible Meta Files
Asset Serialization: Force Text
This seems like a common issue (I looked online and talked to friends). What could be the cause and is there a proper solution?
Answer by KOKOStern · Feb 16, 2014 at 02:28 PM
Solved.
After enabling the Editor options you must delete the Library and re-open the project before pushing up.
Also make sure .gitignore does not have *.meta files.
This is the only place i saw this advice after doing everything else and nothing worked. $$anonymous$$ark this as answered to stress it! ;)you must delete the Library and re-open the project before pushing up
What is the point of regenerating the Library folder as it won't be pushed as it's in the .gitignore?
After re-opening the project all of my objects are gone from the Hierarchy and components detached. I don't want to push up a project with all gameObjects missing.
Probably deleting the Library folder causes a recompile and rebuild of all the meta files after you've changed your project editor settings. Probably there are other ways to trigger this rebuild event, too.
The only solution for me was create a new repository without gitignore file, then in GitHub desktop clone the repo and commit and pushing, upload was good and when I download the repo and working on Unity the project works and no missing prefabs.
Answer by hackerMonkey · May 10, 2019 at 09:06 AM
In Unitys manual it says:
When backing up a project, or adding a project to a Version Control Repository, you should include the main Unity project folder, containing both the Assets and ProjectSettings folders. All the information in these folders is crucial to the way Unity works. You should omit the Library and Temp folders for backup purposes.
Note: Projects created in Unity 4.2 and earlier may not have .meta files if not explicitly enabled. Deleting the Library folder in these projects will lead to data loss and permanent project corruption because both the generated internal formats of your assets and the meta data were stored in the Library folder
https://docs.unity3d.com/Manual/BehindtheScenes.html
So I shall be alright deleting the Library then? I'm using Unity 2018.3.13f1