Skip to content

Instantly share code, notes, and snippets.

@paulhayes
Created July 10, 2017 19:31
Show Gist options
  • Select an option

  • Save paulhayes/f70d81524494dd26ff64717b4c49c5ce to your computer and use it in GitHub Desktop.

Select an option

Save paulhayes/f70d81524494dd26ff64717b4c49c5ce to your computer and use it in GitHub Desktop.
Simple tool for getting command line arguments given to build executable in Unity
using System;
public static class AppArgs {
public static T GetNamedArgument<T>(string key,T defaultValue) {
string[] args = Environment.GetCommandLineArgs();
int index = -1;
for(int i=0; i<args.Length-1; i++ ){
if( args[i] == key ){
index = i+1;
}
}
if( index == -1 ){
return defaultValue;
}
return (T)(Convert.ChangeType( args[index], typeof(T) ));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment