Created
July 10, 2017 19:31
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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