An example of where it would be useful is, I have a project that I want to release on the Amazon App Store and Google Play. If I add plugins to enable various store / platform specific features then the only control I have is to say these plugins are Android. Thing is, I don’t want any trace of the Amazon plugins in the Google Play build and vice versa. Now imagine that I also want to release a paid version and a free ad supported version of the game. I want the paid version to have no on-line requirements, and no funky permissions due to ad libraries or social services. How to do that:
Maintain separate scenes for each and trust that the build process will chop out anything that isn’t referenced. I’m totally happy relying on this for assets like textures, audio, etc. Not so much for plugins. I’ve recently released a game that used a popular Android plugin for a few minor platform specific features. In the Google Play developer dashboard I tick that this game does not use adverts, and it immediately pops up a warning saying “well your APK contains ad libraries, so we ain’t inclined to believe ya”.
Maintain multiple projects and use version control to sync up shared folders. This is how I handled my last one. I use externals to reference shared folders containing all my game’s scripts and assets that aren’t plugin based. It works, but it’s super clunky. It also means it takes up way more space on disk and requires way more time transferring changes to & from VC. It falls apart at the slightest provocation (possibly because I use SVN for version control), and it’s not hard to get my shared folders out of sync either through forgetfulness or some other user error.
Write build scripts that copy/paste or rename folders so they are excluded. No. Just no.
If there’s some editor feature that I’ve missed that makes this super easy then please chime in. In that case I’ll delete the suggestion and throw a party for whoever sets me straight.
Anyhow, how I’d see it working:
You define tags somewhere in the project / build settings (probably Project Settings > Editor). Similar to how you define custom layers or object tags.
The inspector for a folder in the project view has a drop-down where you select which tags apply to each folder (defaults to all). Saves to meta as you might expect.
In the build settings you have a drop-down where you select which tags to build.
Additional member in BuildOptions for people that want to control the build pipeline through scripts.
From the outside looking in, it seems like it would be a relatively simple feature to implement (I may be very wrong). It would make a huge difference to the neatness, flexibility and maintainability of my projects, though.
AFAIK, there is no built-in or a plugin that does this at the moment.
We have also faced a similar requirement working on our previous project: our game had to be built in a few different variations. By variation, i mean different platforms, and different configurations per platform.
This meant we had to configure assets, scenes, plugins, etc per every build variation.
There are different solutions your can do to work around this issue, which will probably cover most of what you need. For example - for scripts, it’s pretty easy to differentiate code per variation using scripting defines (e.g: #if AMAZON).
What you’d like to do (include/exclude certain folders) is not possible with how Unity works. I’ve read about some solutions that suggest that if you move content into a particular folder (.tmp i think) it will be excluded but i never tried this.
What we implemented was a system we called “Workspaces”. It used symbolic links, which is supported both on Windows and OSX. Essentially, we created a bunch of folders outside of the Assets folder. Each folder was assigned a “tag” like you suggested. When setting your project to a certain “workspace”, the system we built would create symbolic links inside Assets to all folders that belong to that tag, so the editor “thinks” these folders are part of the project and include them. At any point you can switch to a different workspace and it would reset the symbolic links and include another set of folders.
It worked quite well though it did had a few shortcomings.
Maybe this gives you an idea on how you can solve this issue yourself for now, until Unity will support this out of the box.
Hence why I posted an idea. If it seems interesting and useful to you then give it a vote so that the Unity team can see it would make a difference.
I’d be interested to hear what the shortcomings are? I tried similar with SVN externals, but it was far too unwieldy to really use in production. Switching between configs was a complicated error prone process that could take quite a bit of time. Plus when you actually move files / folders around switching back to the editor then means it has to reimport all scan through all those files and reimport a number of them.
Thanks for the suggestions anyhow. I’ll have a dig into symbolic links and .tmp folders and see what difference they make.
The shortcomings (as far as i can remember them) were partly related to our implementation (bugs, etc).
Also, we had to decide whether we commit the currently active “workspace” to source control, or whether we should leave that as a setting that is relevant per developer.
The solution itself worked - it did not involve any copying of folders; it only created a link to the actual folders. No copying/moving was involved.
After modifying your current workspace, Unity would reimport all things that were changed, since as far as the editor is concerned, the contents of the projects got updated. This can be a lengthy process, all depending on the content you include per platform.
For us, the game itself did not change apart from a view popups / images. You would generally want to keep most of your project common between all different flavours, and only change very small parts of it, in order to keep maintenance to a reasonable cost (of developer’s efforts and time).
I just upvoted the suggestion. I have a pretty good workaround but it’s not ideal.
Currently, I handle this through organizing my hierarchy so that conditional compilation is accomplished by disabling entire hierarchies from the top level. You can add/remove a tilde (~) from the end of the directory names to suppress visibility to Unity. Unity will entirely ignore all variety of assets below those directories, scripts, geometry or anything else.
This isn’t hard to make part of your build process if you have a little bit of automation. When you add the tilde, all scripts in the project are immediately recompiled. To remove it you’ll need to go into your platform’s file manager, though, unless you build a tool for it.
I use it to simplify building for the Moverio glasses (on Android) and the HoloLens (on UWP).
There really should be a tool inside Unity to do this though.
Thanks for the tips, EddieOffermann. It helped me get over my hurdle of deploying to multiple platforms. I agree that Unity should be doing this by default and invisible to us (aside from elements we add to our scenes).
For those who want to know more about the tilde (~) method, you should review this document:
We tested hiding folders again in 5.4 and 5.5 a while ago using the method of renaming with ~ but Unity’s metadata didn’t work properly and case-related errors appeared in the Editor (OSX) console about half the time making it unusable. We filed a bug which was accepted by QA but hasn’t gone any further yet.
I’m interested in this too.I would love for Unity to have an option on folders like it has on plugins, allowing to exclude/include them depending on the platform !
I actually tried using that but it didn’t work out so well. I advise you to do the same.
For example - our project took a very long amount of time to switch platforms due to many art assets. I’ve tried moving some of the unused stuff to a folder that starts with ~ to avoid having those assets imported, but Unity still processed them (at least, from what i can remember).
Consider a case where the project contains multiple “variatons” or “flavors”. For example : paid vs. free versions, different platforms (under Android there could also be Google play / Amazon versions), etc.
Having a solution that lets you configure different “active” assets according to the active variation is a nice feature.
of course, but the underlying mechanism for this tool isn’t the ~ prefix for folders. We eventually went with something else which i previously wrote about in this thread.
They have to END with “~” not start
As the quoted page states:
“Files and folders which end with ‘~’.”
Besides that, does anyone knows if those files get still included in the build (like the streaming assets) or if they get ignored for builds as well (which is what I’m looking for)?