Search Unity

How to force Unity to clear its Library/Artifacts folder via script (2019.4.1f1)?

Discussion in 'Scripting' started by RedVonix, Sep 14, 2020.

  1. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    422
    We are working on a project where we need to open something in the Unity editor, process it, and then delete the files. We're finding however that - even when using AssetDatabase.DeleteAsset - the Library cache for those files stick around. So after an hour of running, we've got 5gb+ of cached data in Library/Artifacts. We need a way to manually tell Unity "These files are no longer there, you can remove their data from Library". Spent the morning reading Unity documentation and searching forums and Google to no avail.

    Could someone please point me in the direction of who we can tell Unity to clear its Library/Artifacts folder?

    Thank you!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    When I work with problematic repos like this I usually just make a little
    zap
    shell script that I can poke whenever things get out of hand and it blows away areas that keep growing.

    SUPER low-tech I know, but works 100% of the time.
     
    Joe-Censored likes this.
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    What happens if you just...
    Directory.Delete
    the Library folder? Or is that too nuclear?
     
  4. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    Does wiping the Library, e.g. with
    Directory.Delete
    , have any adverse side effects if you do it from code while the editor is running?

    At the very least, it would cause a recompile of all source, right?