If you are a professional game developer, you know the importance of having a solid Continuous Integration pipeline within your project. By making sure to automatize repetitive tasks as much as you can, you are more likely to avoid human errors, and also, greatly increase your development pace. Luckily for us, Unity gives us the ability to access his Editor through command line, and therefore, execute some scripts that are necessary to Continuous Integration.
If you are already a Jedi of Continuous Integration with Unity, chance are high you know the Editor script AutoBuilder.cs. For those who doesn’t know that little piece of code, it gives you the ability to launch a Unity build through the command line by the argument “-executeMethod”. This argument is damn useful! It’s your entry point for any of your automation scripts.
So that’s great! We can execute Unity script through the command line, and even better, we can launch a build by using AutoBuilder.cs! We have all we need, right?
Often into a build process, you need to give some extra parameters that are often specific to your projects, let’s call those “Custom Arguments”. Custom Arguments give more flexibility to your build process by giving you the ability to send set of values inside your game to generate different results.
For example, you could provide Custom Arguments for:
-Filter logs severity
Well, the bad news is that there is nothing built-in Unity that gives you access to do such a thing.
After some research over the web to find a solution, I’ve discovered that many people have fallen into the same problem. So I’ve decided to code the CommandLineReader, a really simple Util script that gives you the ability to read Custom Arguments sent through the command line. Giving you all the flexibility you need to have a solid Continuous Integration pipeline.
You simply have to list your Custom Arguments after the command “-CustomArgs:”. So, for example:
C:\Program Files (x86)\Unity\Editor\Unity.exe [Your_project_repository] -executeMethod [Your_method_name] -quit -CustomArgs:Language=en_US;Version=1.02
To get this information back into the method you executed, you simply have to call the CommandLineReader like this:
That’s it! You can put whatever you want and use it as you need it.
To get the code as well as a working example, you can download it from my Git Repository:
If you find this article/script useful, please leave a comment!