14
\$\begingroup\$

What and why does the Library folder in Unity projects do and why all recommend adding it to .gitignore when working with VCS (version control system)?

Only it can be somehow simpler, and not like in the article that I read, where Library is called "local cache for imported Assets". Yeah, it's clear that nothing is clear.

Why do you need this Library folder if everything works without it? It is removed and it is re-generated when the project starts. What kind of creature is this Library and why does it exist?

\$\endgroup\$
0

2 Answers 2

15
\$\begingroup\$

As you have correctly read, it is a cache.

This means that it is not needed, in the sense that if it is missing it can be generated anew. And it is needed in the sense that if it is present, it avoids the need to generate it anew each time. It does what caches do - make "things" happen faster.

The simplest way to think about it is that project assets have 2 versions, one easy for you to use and another that's easy for Unity to use. So Unity takes the assets you put in your project and prepares them to be easy for runtime use inside the Library folder. This way you don't have to wait for that to be done each time you run the game.

\$\endgroup\$
1
\$\begingroup\$

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. It will takes less time and less space.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ On top of that, if you're working with a team, and not all members of the team are storing their projects in identical folder paths, the library folder will actually be different on each computer, so putting it in source control will be harmful as each team member will be constantly submitting and overwriting unnecessary changes to these files. \$\endgroup\$ Commented Jun 17, 2021 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .