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.

► Exclude files, objects, components from build ◄

Discussion in 'Assets and Asset Store' started by _geo__, May 27, 2022.

  1. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    Hi all,
    I have made an asset which allows you to exclude anything from your build (file, folder, script, GameObject, Component). It's super easy (just right-click and hit "exclude from build").

    ExcludeFromBuildTeaser.gif

    > Asset Store Page <
    https://assetstore.unity.com/packages/tools/utilities/exclude-from-build-222791?aid=1100lqC54
    Full Source Code included.

    Here is the thread which triggered me to grow my home made tool into a full featured asset:
    https://forum.unity.com/threads/excluding-folders-from-build.408375/page-2

    Features
    > Can exclude any file (yes scripts files too), GameObjects or Components
    > Test Mode (allows you to see your changes withou having to start a build)
    > Allows you to make multiple configurations per platform (called "groups")
    > FullSource code included
    > Overview window with handy shortcuts (so you always know which things are excluded and where to find them). You can also scan scenes for excluded objects or components.

    ExcludeFromBuildWindow.png
    If you want to know more then here is the manual (pdf):
    https://kamgam.com/unity/ExcludeFromBuildManual.pdf

    Hope you'll find it useful :)
     
    Last edited: Feb 6, 2023
    Lars-Steenhoff likes this.
  2. like_a_guest

    like_a_guest

    Joined:
    Aug 6, 2018
    Posts:
    2
    Hey, can you use this on folders in packages too?
    Currently having a major issue with a project, that includes multiple build types on the android platform. One library from a package seems to get included and mess with the rendering pipeline, so one build type does not work anymore. Its a .o library inside a package, that is included via package manager. Would this tool be able to exclude the file from build?
     
  3. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    Hi, good question.

    Sadly no. The tool only works on things WITHIN the Assets/ folder. Though package support seems to be an often requested feature. I have it on my todo list to look into it (no promises though).

    One way to solve this manually could be to turn the package into and embedded package and then use #ifdefs to comment out the problematic code segments. Caveat: this does require you to redo the changes for every package update. It's not very maintenance friendly.

    Another solution would be to use a different package manager manifest file for each platform (just an idea, I have not yet tried this myself).

    Sorry I don't have better news for you. I hope this answers your question.
     
    Last edited: Nov 3, 2022
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,289
    Very interesting asset!

    I often make a build in a project with a lot of textures that are not needed/used in the build, but they are in the project as part of an asset that I got from the store, now the thing that unity does is the following, it compresses each and every texture in the project when making a build, taking a long time and if those textures are not even part of the build thats a wast of time and disk space. Do you think that with this asset will allow the compressing of those not part of the build textures will be skipped so I can have faster builds? Thanks
     
  5. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    Hi,
    thank you.

    They way it works is that if you start a build the tool will hide all folders and files which are marked as excluded BEFORE the build starts. The files are then no longer in the AssetDatabase. Then Unity builds. Afterwards the files are made visible again.

    People reported significant build size reductions due to excluded textures. So I think, yes, it should do what you want. Caveat: I have not yet tested this exact (texture compression) use case.

    I am curious: I usually only see long lasting texture tasks after a platform switch, reimport or very first build. I guess you are already using the cache server?
     
    Last edited: Dec 20, 2022
    Lars-Steenhoff likes this.
  6. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,289
    I don’t use the cache server, and yes I do platform switch a lot, I also want to save on disk space by not compressing whats not needed in the build. I will buy the tool as it seems perfect for it.

    In thing that would make it even better if it could detect scene dependencies of textures, but I understand that may be out of scope for this asset.
    Thanks
     
  7. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    I fear I don't quite understand what you want the tool to do here. There are some really good "reference finder" Assets out there which help visualizing what is referencing what. Not sure if that is what you want though.

    I don't mean to push it onto you but I really recommend using it. It makes a big difference. It's one of the first things I enable for any project. Otherwise platform switching is just such a pain.
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,289
    One thing that will be nice to have is a hiding set, that I can enable / disable
    Yea I was thinking about a reference finder that automaticity set the excude tag to a folder if not referenced by the scenes in the build

    I see there is now https://docs.unity3d.com/Manual/UnityAccelerator.html accelerator as cache server only works on older unity versions. I will have a look again there. bit its still wasting a lot of disk space that I rather keep on my system SSD. thanks for the tips.
     
  9. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    Ah okay, now I think I understand. Though in builds these unreferenced things should not be included (or processed) anyways (unless they are in a special folder like Resources, StreamingAssets).

    It might be a handy feature to "hide" things in the Editor to keep the project clean after importing 3rd party assets. I'll think about it. But I guess this would become a new asset since it's not really in the scope of "exclude from build".

    Thanks for the feedback :)
     
    Lars-Steenhoff likes this.
  10. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,289
    Or textures, they are always compressed no matter if they are in the build or not.

    I think unity has some plans to change this later. but seems to take forever to get released.
    First Link here #8
    Second one #6
    https://forum.unity.com/threads/exc...build-from-compression-at-build-time.1317945/

     
    _geo__ likes this.
  11. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    795
    I understand your problem and I agree that asset importing is a bit of a pain.

    I think the key part is "The compressed result is still an import artifact and it is cached in the asset database ..". Usually once you have the cache server (accelerator) enabled and you have built at least once for every target then you should have cache hits for about 99% of all textures and import times won't play a big role anymore (for building or platform switchting). But I am not entirly sure how the "uncompressed texture" workflow works (I rarely use uncompressed textures).

    I assume every time you do a platform switch the import artefacts are thrown away unless you have a cache server where they are stored. My understanding of the cache server is that it exists to retain the imported results and share them among coworkers. In your case (no cache server) all those textures have to be reimported at build time. I think you will have massive gains in build times once you switched to the cache server / accelator workflow.

    I think the topic may be a little out of scope for this thread though.
    Maybe continue in the original thread you linked?
     
    Lars-Steenhoff likes this.