Search Unity

Can we remove assets from the project at runtime?

Discussion in 'Editor & General Support' started by SoftwareGeezers, Jul 29, 2019.

  1. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    I have an intro video and, as there's little chance of anyone watching it more than once, I was wondering if there's a way to remove the asset from the project and free up space, especially for the mobile version.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You can include the asset in an AssetBundle, and assuming that is your project's only AssetBundle, you can delete it using ClearCache. If you are using several AssetBundles then you won't want to do that though. I don't believe there is a way to delete individual AssetBundles right now.

    https://docs.unity3d.com/ScriptReference/Caching.ClearCache.html

    You could also load the asset at run time from StreamingAssets and just delete the file(s).