- I have some Scripts/Assets for demos and internal tools.
- All those Scripts are included in my project when I build
You are no using special folders or platform-dependent compilation to exclude Scripts/Assets.
Currently, there is no way to exclude directories from the build process, but there are some workarounds:
Suppose you have an internal tool that only adds functionality to the editor itself. In that case, you can put all the scripts inside a folder called Editor anywhere inside the Assets folder. If you require assets for your tools like images or models, create a Resources inside your Editor folder to exclude the assets from any builds you make.
You can get a similar effect by using assembly definitions. To do that, create a folder with the scripts you want to exclude and create an assembly definition asset inside. On the inspector in the included platforms section, only select Editor. This way, the scripts won't be included on any build.
To exclude specific scripts, you can use the macro UNITY_EDITOR at the start of your code.
... your class/code ...
You can also use this to exclude parts of your code instead of the whole script. Like extra debug code or methods only intended for use in the editor. One example could be a method that skips a level with a particular input.
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 need to remove the symlink and recreate it after you make a build.
MyProject/Assets/TestCode >> OTestCode