How command line arguments are passed in FPSSample when we start the game?

Hello,

I have been studying the FPSSample recently. Currently I’m studying the Game.cs
In the Awake() method, I stumble across this line :

var commandLineArgs = new List<string>(System.Environment.GetCommandLineArgs());

I know what this function does. But the thing I have trouble understanding is how FPSSample passes in the arguments into the command line.
When I hit “play” in the editor, or click play on a standalone build, some arguments are automatically passed into the command line, to be fetched by System.Environment.GetCommandLineArgs() later on. How does FPSSample do this?

I have spent quite a lot of time to find the answer. I can’t seem to find a .bat file that does this. After analysing console scripts I couldn’t find the answer too. I think I don’t understand what is going on behind the initialization process.
Could anyone help? :frowning:

1 Like

Think I found out what I didn’t understand before.

The System.Environment.GetCommandLineArguments() will always fetch some default arguments when we launch a Unity game, e.g -projectpath, game instance name etc.
If we want to provide any extra arguments like -batchmode, -serverport etc. we have to do it through command line when launching the game.

And command line != the console in the FPSSample game. They have nothing to do with each other. Previously I thought they do xd

2 Likes