• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by cregox · Nov 22, 2011 at 05:15 PM · libraryversion-controlrecovery

How to prevent library to keep rebuilding itself with external version control?

This issue is about 2 years old now (for me). Current answer is: can't be done.

I'm using git, but I believe this doesn't depend on which one you're using, even if it's Asset Server.

Keep in mind I'm following everything in the manual plus what I've found around.

The library rebuild can take anywhere from minutes to even hours, depending on how much Unity thinks it needs to work.

Although this is not a critical issue (it doesn't stop the workflow) it's still huge. We're not fully using git thanks to this issue. It's impractical to go back in history to an old commit or even simply changing a parallel branch can become a nightmare. So we always avoid to do it, unless it's critical.

There are many things that will trigger a library rebuild, here are a few known ones:

  • Touching the file. No brainer here. The more you touch, the more time it takes.

  • Moving / renaming files outside of Unity. Specially noticeable if they are video files.

  • Keeping timestamps in git is not enough. At least in the way I could do it.

  • Whenever we checkout in a new machine - this will add an extra library rebuild because eventually have to change back the build platform settings to Android or whatever.

The question is in the title: How to prevent the library to keep rebuilding itself like that?

As for plausible expected answers...

I know it wouldn't work if I commit the library along because even just checking out an old commit and back to same one before opening Unity, it will also trigger a library rebuild.

The "Library Network Cache" called "Cache Server" does not solve any of these issues. It does make it faster, some times, specially for checking out on a new machine. But it's still far from good. It still can take up to hours.

[1]: http://answers.unity3d.com/questions/188352/how-to-prevent-library-to-keep-rebuilding-itself-w.html

Comment
tomka
syclamoth
luizgpa
zen-ventzi
MrGuardianX
Xonatron

People who like this

6 Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tomka · Jan 24, 2012 at 02:18 AM 0
Share

I'm getting a very similar issue with 3.5b6. Just upgraded from 3.4 today and now about every 5-10 mins this popup (http://imgur.com/SrNGU) appears for about 30-60 seconds. It's very frustrating.

I noticed the console contained the error message "Rebuilding library because the asset database could not be found!"

avatar image cregox · Jan 24, 2012 at 12:58 PM 0
Share

Plus if you want just the Library Network Cache it will cost you the whole $500 from Asset Server because it's bound to it.

avatar image Tyler 10 · Jan 24, 2012 at 06:41 PM 0
Share

At my company of we tried using subversion with unity project folders and it never did work. We ended up checking in .zip's of the project rather than the project folder. This defeats the purpose of having multiple people work on and commit files but it did save us from corruption.

Don't know if thats an option for ya!

T

avatar image cregox · Jan 24, 2012 at 07:06 PM 0
Share

@Tyler we're using GIT and keeping separate pre-compiled library folders in each machine. Kind of what you're doing, except the commit is there and there's no corruption. Still this doesn't work for using old commits neither moving folders. It only works for new machines and tags and labels - or as much as we want to manually keep track of library folders while each machine's hard disk also needs to have room.

avatar image Tyler 10 · Jan 24, 2012 at 07:15 PM 0
Share

Hmm, well, I know if you are checking in your Assets folder - but not the Library folder, you will need to rebuild the library database each time you open it. At least I think, I am not a pro or anything :D. I know that if you change the name of a file in code and then give that Assets folder to someone else it will have to rebuild the Library folder on that persons computer. Name changing is such a pain haha. Even in Flash Builder projects similar stuff happens. I moved to checkin in .zips of the whole actionscript project too because of similar issues. Ill watch this thread and see if you figure it out.

Show more comments

2 Replies

  • Sort: 
avatar image
Best Answer

Answer by lh · Jun 04, 2013 at 10:15 AM

Summary: don't let your version control system rewrite history or re-perform changes that were previously made.

Unity will always reimport assets if their timestamp changes. If you want to make a backup of your project to in case of accidental re-imports, you must copy all folders as well as timestamps. Windows/OSX copy functionality does not preserve timestamps, so you will need to use a helper application. (In OSX terminal or Cygwin, "cp -a" does the trick.)

When you check out on a new machine, the build platform isn't specified because you haven't checked that file in. Do it and you'll never have this problem. To find out where the platform build settings are stored, make a small project, change the build platform, and see which files changes. It's in Library/ or ProjectSettings/.

Here's a trick about using Git and avoiding reimports: Always keep a project backup (and backup when in a state where Unity doesn't need to re-import anything). If you do some Git operations (like svn dcommit or rebase) and your file tree ends up mostly the same as it was before besides that the modification times have changed, you can salvage the situation: use a syncing program like rsync to copy your whole project backup (except the .git folder) over your main project, deleting any differences (rsync -a --delete). At this moment, your recent changes will not be reflected in the working copy, so use "git checkout" and maybe "git clean" to iron out the differences. Now when Unity is opened, it will only re-import the files that are actually different, regardless of any changes that may have been done and undone.

Also, if you must rename an asset, do it within Unity and not the filesystem. That way Unity knows it doesn't need to re-import. (Your coworkers will still need to re-import that file/folder, so do this sparingly.)

Comment
cregox
Bunny83
guneyozsan

People who like this

3 Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cregox · Jun 04, 2013 at 11:25 AM 1
Share

All seems very reasonable, but unpractical. I don't think we can implement any of those tricks into our procedures. The whole point of using a versioning system is so we don't have to manually handle it all, as you're suggesting. Because it's so much work to do without it, that we just don't do it. Have you worked in a big project and applied any of those hints? Despite it all, it is the best answer so far ( out of 2 :P ) with some good insights on how it works (though I haven't tested). I think it still doesn't answer the question at all, tho.

avatar image lh · Jun 04, 2013 at 11:33 AM 0
Share

Keep in mind Unity was created before distributed VCS became really popular. Unity assumes you're not going to locally commit and uncommit and recommit your changes. Unity thinks that when you change a file, you're gonna change it once. Until recently, rebase-like operations were rare and usually done by hand.

If you use version control for simple operations, Unity will not do unnecessary reimports. Want to fix the root of the problem for you and everybody else? Patch Git so it stores timestamps before a rebase and restores the timestamps afterwards if the file is the same as the old version (if the operation involved undoing/redoing changes).

And I do use the tricks I mentioned. It's not convenient, but it's not slow or overly confusing, given that I understand the issues at work. Furthermore, I consider it utterly necessary, given that a full reimport would waste at least half my work day. A less complex trick: don't use git svn, git rebase, or git reset.

avatar image cregox · Jun 04, 2013 at 11:53 AM 0
Share

I'm not asking how it works or why it doesn't work. I just want to "prevent library to keep rebuilding itself with external version control".

I would try and patch git so it would store timestamps, if it can be done (no idea if you mean using some trick or actually getting the git source code and hacking into it) and if it would really solve the issue.

As for you're really using those tricks, I may not be reading it right. How big (in bytes) is your project? Are you using mostly git? In what situation you do those manual backups? How many people involved? I really can't see how going through all this problem would be any advantage to waiting the library to rebuild.

The problem isn't only about wasting half the work day. This can easily sum up to a whole work day or weeks. And how much extra work we do trying to avoid that - so it's already taking a lot of time anyway!

avatar image lh · Jun 04, 2013 at 12:11 PM 1
Share

The serious and simple answer is to not rewrite history. Don't use Git as an svn frontend, and don't use its history-rewriting features. I use these tricks and more complex ones, but my coworkers don't. I'm helping one other programmer back up his working copy with scripts, but I think for the others, it's more trouble than it's worth. And the repo is SVN (>4GB), but I'm using git-svn as a frontend.

avatar image cregox · Jun 04, 2013 at 12:22 PM 0
Share

You should add that as your main point on your answer. I agree. Simple and only true unfortunate answer so far is indeed "do not rewrite history". Because Unity can't really handle it. Be it for timestamps or external renames, it's really poor at it, as you said.

For reference, we are using only git (no svn hassle) and just the working dir is already at 12gb. 45gb if you count .git folder.

Show more comments
avatar image

Answer by tomka · Jan 24, 2012 at 10:24 PM

It seems Unity 3.5 no longer supports files that begin with a period (a ".") so a filename such as ".somefile.prefab" will cause Unity some to have some issues.

The fix for this is to rename your file so that it no longer begins with a period.

Specifically I was having this problem with 2D Toolkit which creates a file called ".tk2d.prefab". Renaming this file to "-tk2d.prefab" and fixing up the tk2d codebase so that it loaded this file instead resolved the issue for me.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cregox · Jan 26, 2012 at 12:23 PM 2
Share

This sounds like a nice tip... But far from an actual answer. Which "resolved issue" are you talking about? It's certainly not the same as I pointed in the question.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to fix /Library/ conflicts in GitHub repo for Unity project? 1 Answer

Why does text mesh pro keep littering my git log? 0 Answers

What kind of "data loss" from upgrading? 0 Answers

How to resolve different GUIDs in versioning? 1 Answer

How to properly use git with a team? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges