Notifications
Article
Move Plugin Code to "Plugins"
Published 3 months ago
145
0
Not just annoying: the fact that Asset Store plugins do install themselves anywhere they like will also slow you down! Clean up the plugin mess, even if it may require fixing someone else's code.
It is good practice to keep your Unity project's folder structure clean. Some developers already go through the hassle of moving Asset Store and other C# plugins out of the way. Though, if you are not moving them under the project's Assets/Plugins folder their code will still recompile every time you make a change to your own scripts.
All 3rdParty code, and even some of your own code that you rarely change, should be stored somewhere under the Plugins folder!
Because it makes a great deal of a difference where you place code in your project. Case in point: this VR project I have seen today for the first time. My first order of business: check what the turnaround time is for changing scripts.
Changing just one line in a script and measuring the time from returning to Unity Editor until the spinning wheel at the bottom right corner goes away is enough for a quick assessment. Do this two or three times with a stopwatch and you have a good idea how long the developer(s) sit idle on every script change. In this project ...

It turned out to be 25 seconds!

I found that some Asset Store packages where at the root folder, many more where moved away but inside a folder named "ExternalAssets". One of the plugins and the one with the most scripts by far was Photon.
I moved the entire contents of the ExternalAssets folder to Plugins. But since the project had been used like this for many months, close coupling was created to the plugin code (specifically Photon) from the project's core code.
Because of this, I had to make several code fixes to successfully compile the project again. This is due to the fact that the code under Plugins is compiled before any other code. So referencing any type (class, enum, etc.) of a script not under Plugins in a script that is under Plugins will lead to a "missing reference" compile error.
This is why it is so important to move the plugin code right away, so these closely coupled references can never be made in the first place! There's always an acceptable alternative or workaround other than modifying the plugin code directly. It may take slightly more effort but it's always worth the hassle.
After moving and fixing everything up I made the same script change as bfeore and again measured the time it takes until you can continue working.

It was now only 12 seconds!

That's 13 seconds saved every time a script is changed! Assuming 6 hours per day with 20 script changes per hour the project was wasting 2 hours per week per developer! And this simply because the project's plugin code hadn't been moved to the Plugins folder!
PS: With Assembly Definition Files you can actually enforce proper order of dependency and inversion of control in addition to saving more script change turnaround time within your own code.

Tags:
Steffen Itterheim
Unity Enthusiast, Team & Tech Lead - Manager
7
Comments