Have you ever wanted to simply disable a script while you were developing your project?
WebplayerTemplates is the answer.
A little bit of backstory:
When we build a webplayer project, Unity embeds the player into an HTML page so that it can be played in a browser. The default page is very simple. It’s just a white background and some minimal text. Unity has three different variations of this basic page which can be selected from the Player Settings inspector. Player Settings is available from either the Edit Menu with Edit > Project Settings > Player, or by clicking the “Player Settings” button on the Build Window.
In general, if we need to embed the player into a custom page, we don’t have to rewrite our html page every time we build, or copy that webplayer over to a prebuilt page. We can create our own custom webplayer templates and have Unity build the webplayer directly into our custom page.
We can find out more about using webplayer templates on this page of the documentation. This page gives an overview of the process and includes some sample webplayer template code.
What this means to us.
The code needed to build the webplayer template is, well, code. Unity will, in most cases, try to compile this code. Unity, however, has been trained to ignore any code found in a folder called WebplayerTemplates.
We can use this to our advantage.
Because Unity is ignoring any code in WebplayerTemplates, we can simply pop any scripts we don’t want to compile into that folder.
If we want to test an alternative to a script or a class, put one copy into WebplayerTemplates, and test with the other. Swap them around to try a different version. If we want to remove a buggy or problematic script from our project temporarily, move it into WebplayerTemplates.
This is even more important as Unity won’t update the editor if there are compilation errors.
If we import a new package, or are writing a new script, and there are compilation errors, simply move the offending script or scripts (we can move as many scripts or folders at once) into WebplayerTemplates, and let Unity compile successfully.
This is a simple trick that I use all the time.
One note, however: Spelling & spacing are important here! Capitalization is not! It must be spelled exactly: WebplayerTemplates with no space between Webplayer and Templates, but it could be cased as webplayertemplates, WebPlayerTemplates or whatever you see fit.