Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I push the Unity Library folder to Github

Tags:

github

unity3d

For a school project me and 14 other people are making a game in Unity. For this project we are using a couple of packages, important for this question are TextMeshPro and the new input system from Unity. To fix a couple of bugs we are experienceing we have had to modify 2 code files from these packages and everybody in the group needs these files. The problem is that these files are located in the Library folder of Unity and I have read that a couple of people are saying to no push this folder to github to prevent merge conflicts.

So my question is: Do I push the library folder to github in this specific case?

like image 572
Ino van den Berg Avatar asked Jan 14 '20 23:01

Ino van den Berg


People also ask

Do you need Unity Library folder?

No, the Library Folder is not required in the repository and it should not be checked in. You do not need to include your Library folder in the code repository, as Unity Cloud Build automatically generates the Library folder when it processes your project for the first time.

What is the Unity Library folder?

Library folder is storing your imported assets as document says. If you delete it Unity can create and install dependencies on it. When you add it your . gitignore file vcs like git doesn't track this files and when you push your project to repository, you will send less files to server.

Is GitHub good for Unity?

Git helps millions of developers write and collaborate on code, but it's not always a practical choice for building games. With the GitHub for Unity extension, Unity game developers (artists and programmers alike) can better integrate Git and GitHub into their workflow, even if they're versioning large binary assets.


2 Answers

to answer your title

NO

Simplest way to decide this would be to use the "official" .gitignore for Unity from GitHub itself.

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# 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
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

As you can see the Library folder is the very first thing ignored actually with good reason (see Iggy's answer).


possible exception

However personally it made sense to me to also keep the .asset files from within the Library folder. This is a bit inconvenient but here things like Buildsettings, TargetPlatform etc. are stored so you don't have to switch it manually everytime you clone.

So I always add this exception to .gitignore

!/[Ll]ibrary/*.asset

Read more about it in my answer to Cleaning up and Migrating existing Unity project into new one or another PC.


answering your actual issue

I don't know what kind of bugs you got with the TMP but you should not alter any code from packages at all!

As you noted this are only temporary changes if they are stored at all and not reverted immediately by the PackageManager!

From this post the official answer from Unity Technologies is

Yes, currently [May 22, 2019] the way to develop a package is to copy/move it [from the Library folder] to your project's Packages folder.

This converts the package into an embedded package which you now can alter and push together with the Packages folder.

like image 140
derHugo Avatar answered Sep 25 '22 16:09

derHugo


Documentation

Unity reads and processes any files that you add to the Assets folder, converting the contents of the file to internal game-ready versions of the data. The actual asset files remain unmodified, and the processed and converted versions of the data are stored in the project’s Library folder.

Using internal formats for assets allows Unity to have game-ready versions of your assets ready to use at runtime in the editor, while keeping your unmodified source files in the the assets folder so that you can quickly edit them and have the changes automatically picked up by the editor. For example, the Photoshop file format is convenient to work with and can be saved directly into your Assets folder, but hardware such as mobile devices and PC graphics cards can’t accept that format directly to render as textures. All the data for Unity’s internal representation of your assets is stored in the Library folder which can be thought of as similar to a cache folder. As a user, you should never have to alter the Library folder manually and attempting to do so may affect the functioning of the project in the Unity editor. However, it is always safe to delete the Library folder (while the project is not open in Unity) as all its data is generated from what is stored in the Assets and ProjectSettings folders. This also means that the Library folder should not be included in version control .

like image 37
Iggy Avatar answered Sep 26 '22 16:09

Iggy