Programs must be written for people to read,
and only incidentally for machines to execute.

Unity – Custom Arguments through command line

Category : All, Code · by Dec 31st, 2013

Command Line

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:
-Localization Code
-Version Number
-A/B Testing
-Filter logs severity
-Enable/Disable features

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!


(2) comments

1 year ago · Reply

Hi, I’m trying to do something similar of what you do in your script, and maybe you could help me.

I explained my problem here.

I have an additionnal question. If I build my game once, is it possible to use your script without building it again, or if I want to execute my game with command line arguments, I would have to build it with the arguments given and then execute it?

Thank you for this script

1 year ago · Reply

Awesome – this is exactly what I was looking for!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image