Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Cleaning Unity project disk space

Discussion in 'General Discussion' started by RestlessSwords, Jun 24, 2021.

  1. RestlessSwords

    RestlessSwords

    Joined:
    May 9, 2021
    Posts:
    26
    - i know i can delete directories i used as build targets
    - can i (safely) delete "Library" ? (i assume it gets re-built during builds)

    given many unity projects, these directory space start to add up quickly
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,751
    Library gets rebuilt when you load the editor, not builds. This is a problem that you either need to solve with your workflow or additional storage. It's not really something that can be practically handled otherwise.
     
    angrypenguin likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You can safely delete the Library folder. If you use a custom Unity layout, make sure you save it before deleting the Library. Last time I checked, the current layout is stored in the Library folder, but saved layouts are stored outside of your project folder entirely so they can be shared between projects. Note that much of the Library folder is rebuilt the next time you open the project in the Editor, which can be a long process depending on the size of the project and the performance of your computer.

    What I do personally about this is I just expect a dev workstation to need more storage than your typical desktop or gaming computer. So for example my laptop, which I do most of my work on lately, came with a 512GB SSD, for about $100 USD I added another 1TB SSD. Any projects I'm not actively working on I either zip them up and move them to a cheap NAS, or for ones in version control I am free to just delete them from my computer. That's a nice thing about version control by the way.
     
    Socrates likes this.
  4. RestlessSwords

    RestlessSwords

    Joined:
    May 9, 2021
    Posts:
    26
    Perhaps i should clarify. i am not worried about space in my current development project. what i am trying to optimize is long-term disk usage. so if i have 10 or twenty projects over time (including downloaded examples, CwC tutorial prototypes and CwC Challenges, etc, i just want to clean old projects as much as possible but still be able to rebuild them in the future if i want to. so far i am deleting all my old project build targets (*especially* UWP builds , and now the library folder). this seems the best approach.
     
    angrypenguin likes this.
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,514
    Then that seems pretty reasonable, yes. You only need to keep the stuff you'd check into version control. The rest can go.

    On that note, I have a better suggestion if you have a semi-decent internet connection: Put your projects in an online version control repo, back up the important ones to an external HDD or something like that (or a USB stick for a cheap-and-cheerful option), and then remove them entirely from your workstation.

    You can get them back if you need to by cloning / copying, and they won't be cluttering up your workstation at all.

    There are a bunch of online repos which are free and have generous storage allocations. I use Azure DevOps, but there are quite a few others.
     
    Ryiah likes this.
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    BackBlaze (an unlimited backup service for $6/mo) can be good for the latter if you have a decent connection.
     
  7. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    OneDrive is also a viable alternative for many of us. I'm paying just under $8 a month for Microsoft Office subscription( a necessary evil) anyway, so the included 1TB of OneDrive space is nice.

    You can have it just do it automatically if you want to put your stuff in the folder on your PC. Or you can upload it all and then set OneDrive to not sync that specific folder to your PC. In my case I just leave it alone on my PC as an extra backup.
     
  8. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,514
    For backup purposes that stuff is great. It's cheap, remote storage with easy access. But be warned: many people have had projects corrupted by directly working in a folder synchronised with this kind of tool.

    The issue is that those services work by synchronising individual files, as opposed to sets of interrelated files (eg: a Unity project where assets refer to and depend on one another). It works fine as long as there are no hiccups in the synchronisation process. As soon as there are hiccups things get very risky, particularly if there are multiple PCs involved. If you're working on a team just... do not do your work in synchronised folders.

    Even without hiccups, synchronising the Library folder is both a major minefield and a huge waste of bandwidth.

    There are many good reasons that large organisations use stuff like OneDrive / Google Drive / DropBox / etc. for file sharing and transfer but not for project storage.


    TL;DR: Those tools are great for backup, but terrible for working folders.
     
    Ryiah likes this.
  9. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    100% good advice. I'm not storing anything that is currently being used in such folders. I'm using github for the folder itself. Then I have EaseUS copying daily backups to both the OneDrive folder and a local external HD. Since I'm never working with what is in the OneDrive folder, I never have any of those issues you mentioned. So I have 4 total backups, one of which is of the source control nature(which is on github), 2 local(1 internal(OneDrive), 1 external HD), and one non-git cloud(OneDrive). If space was a concern, I could certainly stop doing it to the internal OneDrive, and do backups to the OneDrive to a folder that doesn't sync to the PC.
     
  10. RestlessSwords

    RestlessSwords

    Joined:
    May 9, 2021
    Posts:
    26
    Some good thoughts and suggestions. What I have settled into as my process is:
    1) make an improvement/change, spend a few hours fixing it
    2) when it works, export the project into an exports/backup directory, typically done 2 or 3 times a day
    3) when there is significant new function to be tested or given to friends, also export that version into cloud site
     
  11. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,913
    You just described a version control system. Except that can merge and more safe and less manual work.
     
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    Not to mention version control allows you to view the history of a file and make comments on the commits.
     
  13. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,324
    Honestly, just use git/version control. What you're doing is the same thing as versioncontrol, except it is more work and more error-prone.
     
  14. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,000
    In my opinion you can safely delete the Library folder for old legacy projects to optimize space. Not because it will just get rebuilt when you open it in the editor ( which it will ), but that in my experience whenever I do return to these projects the specific version of Unity is long gone from my machine and the whole project library will more than likely get rebuilt anyway in a new version of Unity.

    I like removing the Library of old projects as they are just full of tens of thousands of files, moving or copying these takes forever even on SSD's and are grossly inefficient for uploading over the internet as each file has an overhead. If I ever do back up the library folder i'll just zip it up first.

    I've only ever had one client who insisted that I maintain and back up the Library folder because in their experience the project kept getting corrupted, only to discover they never source controlled the project meta files!
     
    Ryiah likes this.