Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding Library folder from Git for Unity project causes scene to be lost

Tags:

git

c#

unity3d

I've gone through all the recommended steps to prepare a Unity project for a Git repository following the directions here:

Unity Git - Ignore Library

I've correctly setup the .gitignore file etc.

However when I clone my newly created Git repo on a different machine I noticed that my scene, assets etc. are missing. The scripts seem to be there.

I noticed that when I copy over the Library folder the missing things (scene, assets) come back.

I'm assuming that there is something in the Library folder that just can't be ignored or that the "forcing assets to text" just isn't working properly.

I'm using Unity 5.3.5f1.

I'm still fairly new to Unity/Git etc. so I may have overlooked something obvious but I've followed all suggested directions.

Any help would be much appreciated.

like image 812
Arnie Avatar asked Jun 25 '16 02:06

Arnie


3 Answers

apparently Unity has changed the Library Folder many times in Unity 4.X that folder could be ignored. Now, it seems not.

I did some tests and the huge junk of files are for my in the ShaderCache and this folder seemed to be fine to delete. The other Folders should not be touched.

https://forum.unity3d.com/threads/26-581-bin-files-in-library-shadercache-folder-can-i-delete-these.326312/

like image 188
Tower Jimmy Avatar answered Nov 10 '22 01:11

Tower Jimmy


Fell into same problem with Unity 2020.3

Some research showed that was needed files LastSceneManagerSetup.txt, CurrentLayout-default.dwlt for scene. And EditorSnapSettings.asset, EditorUserBuildSettings.asset for game window, game view and UI.

Maybe, I miss some other settings, so I saved files in Library root and replaced /[Ll]ibrary/ with:

/[Ll]ibrary/APIUpdater/
/[Ll]ibrary/Artifacts/
/[Ll]ibrary/BuildPlayerData/
/[Ll]ibrary/PackageCache/
/[Ll]ibrary/PackageManager/
/[Ll]ibrary/PlayerDataCache/
/[Ll]ibrary/ScriptAssemblies/
/[Ll]ibrary/ShaderCache/
/[Ll]ibrary/StateCache/
/[Ll]ibrary/TempArtifacts/
/[Ll]ibrary/UIElements/
like image 27
V D Avatar answered Nov 09 '22 23:11

V D


Scenes are not entirely missing, as you can simply load them from Assets/Scenes. Their original order in the scene hierarchy, however, is lost.

I did even more tests than Jimmy and found out the only required things from Library are StateCache folder and LastSceneManagerSetup.txt file (less than 2 kB total in my case). Everything else located in Library folder can be safely removed.

Save these two:

  • StateCache/
  • LastSceneManagerSetup.txt
like image 31
szymmirr Avatar answered Nov 10 '22 01:11

szymmirr