12

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?

3 Answers 3

19

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.

3
  • The two lines @inovandenberg is referring to use deprecated Types and so these lines MUST be corrected or you can not use TMP. These Lines should be corrected by Unity. I suppose no one has reported this issue to them...
    – David
    Commented Feb 20, 2022 at 20:40
  • @David To fix a couple of bugs we are experienceing we have had to modify 2 code files from these packages this doesn't necessarily mean they are bugs in the packages though .. it can as well be an issue on the user side or a limitation of the packages specific to the way OP were using them. Also if there was a big in the packages itself I would be quite confident that they are fixed by now, over two years later ;)
    – derHugo
    Commented Feb 21, 2022 at 6:40
  • Actually I had to fix those to issues myself just last night for Unity 2021. So, unfortunately they are not up to date. I suppose if TMP is only intended to work for older versions of Unity they wouldn't be bugs, but I would think that the intent would be to keep them up to date which would make them bugs...
    – David
    Commented Feb 21, 2022 at 10:17
7

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 .

0

As mentioned in the previous answers, you do not NEED to add the Library folder to version control but if you do not, BE SURE TO DELETE IT AFTER CHANGING BRANCHES or it will no longer reflect the current branch and you will likely have breaking errors and glitches...

Not the answer you're looking for? Browse other questions tagged or ask your own question.