Excluding Scripts and Assets from builds

  • I have some Scripts/Assets for demos and internal tools
  • All those Scripts are included in my project when I build, even though my scenes do not reference them in my asset bundles. 
You want to create a demo, prototype or internal tools. After that, you want to work on your final project, and all those scripts are included in your project when built.
Currently, there is not way to exclude directories from the build process, but there is a workaround:
  • To exclude specific scripts, you can use the macro UNITY_EDITOR at the start of your code and it will be excluded for builds. 
... your class/code ...
  • To exclude directories, you can use symlinks (symbolic links). Try putting the scripts you want to exclude in a folder outside the Assets folder and create a symlink into Resources that points to that folder, so when you want to exclude those assets, you just need to remove the symlink and then recreate it.
MyProject/Assets/TestCode >> OTestCode 
More Information
More information about Platform Dependent Compilation: 
More information about special folders, which can be used to exclude assets with special folder names:

This article applies to Unity versions 5.0+

Was this article helpful?
3 out of 5 found this helpful
Have more questions? Submit a request


  • -3
    amnah rababaa

    i have purchased  VReasy asset ,,,when i importing it to unity its tool menu is not appeared in the upper bar ,,how can i fix that ??

  • 1

    Good point!

  • 0
    Hugo Zink

    There is already an official way to do this, and it's by putting the scripts and resources in any folder called "Editor". If you make a tool that is only ever used in the editor, you oughta put all of its assets inside a folder called "Editor" and it will not be included in the build at all. Symlinks are overkill and #if statements are ugly.

Please sign in to leave a comment.