Class NetCommandLine

Namespace
Unity.Multiplayer.Core

Reads session settings from a process command line onto a NetConfig, so a headless server build is configured by its launch line: Server.x86_64 -batchmode -nographics -mode server -port 7777 -transport websocket.

public static class NetCommandLine
Inheritance
NetCommandLine
Inherited Members

Remarks

Recognised arguments (names ignore case; each takes its value as the next argument or after =, as in -port=7777):

-modehost, server or client (Topology).
-address / -ipServer address to join, or local address to bind (Address).
-port1-65535 (Port).
-transportudp, or websocket / ws (Transport).
-tickrateTicks per second (TickRate).
-maxplayersPlayer cap (MaxPlayers).
-nameThe server's name (ServerName).
-passwordThe server password (Password); MINDATTIC_SERVER_PASSWORD is safer, since a command line is visible to other processes.
-joincodesauto, none, relay or rendezvous (JoinCodes).
-rendezvousRendezvous service base URL (RendezvousUrl).
-rendezvoussecretIts registration secret (RendezvousSecret); the environment variable is safer, since a command line is visible to other processes.
-publicaddressAddress players reach this server at (PublicAddress).
-publicportPort players reach this server at (PublicPort).
-netsimSimulated network conditions: none, broadband, mobile4g, mobile3g, lossy or custom (Conditions).
-botLaunches this process as a bot client playing that role (BotRole): it starts no session by itself and shows no menus; the bot runner joins (see BotCommandLine).
-latency / -jitter / -lossSimulated milliseconds of delay, milliseconds of jitter and percent of packets lost. Each switches to Custom, keeping the other numbers of the profile chosen so far (UseCustomConditions()).

Anything else is ignored, because Unity and the OS put their own arguments on the same line. A recognised argument with a missing or unreadable value is reported in Errors and leaves that setting unchanged.

Fields

AddressArg

Selects the address to join or bind.

public const string AddressArg = "-address"

Field Value

string

BatchModeArg

Unity's batch-mode switch; its presence marks a headless run.

public const string BatchModeArg = "-batchmode"

Field Value

string

BotArg

Launches a bot client playing the given role (BotArg).

public const string BotArg = "-bot"

Field Value

string

IpArg

Alias of AddressArg, matching Unity Transport's own -ip.

public const string IpArg = "-ip"

Field Value

string

JitterArg

Sets the simulated jitter in milliseconds (custom conditions).

public const string JitterArg = "-jitter"

Field Value

string

JoinCodesArg

Selects the join-code provider: auto, none, relay or rendezvous.

public const string JoinCodesArg = "-joincodes"

Field Value

string

LatencyArg

Sets the simulated latency in milliseconds (custom conditions).

public const string LatencyArg = "-latency"

Field Value

string

LossArg

Sets the simulated packet loss in percent (custom conditions).

public const string LossArg = "-loss"

Field Value

string

MaxPlayersArg

Selects the player cap.

public const string MaxPlayersArg = "-maxplayers"

Field Value

string

ModeArg

Selects the topology: host, server or client.

public const string ModeArg = "-mode"

Field Value

string

NameArg

Sets the server's name.

public const string NameArg = "-name"

Field Value

string

NetSimArg

Selects the simulated network conditions profile.

public const string NetSimArg = "-netsim"

Field Value

string

NoGraphicsArg

Unity's no-graphics switch; its presence marks a headless run.

public const string NoGraphicsArg = "-nographics"

Field Value

string

PasswordArg

Sets the server password.

public const string PasswordArg = "-password"

Field Value

string

PortArg

Selects the port.

public const string PortArg = "-port"

Field Value

string

PublicAddressArg

Sets the address players reach this server at.

public const string PublicAddressArg = "-publicaddress"

Field Value

string

PublicPortArg

Sets the port players reach this server at.

public const string PublicPortArg = "-publicport"

Field Value

string

RendezvousArg

Sets the rendezvous service URL.

public const string RendezvousArg = "-rendezvous"

Field Value

string

RendezvousSecretArg

Sets the rendezvous registration secret.

public const string RendezvousSecretArg = "-rendezvoussecret"

Field Value

string

TickRateArg

Selects the tick rate.

public const string TickRateArg = "-tickrate"

Field Value

string

TransportArg

Selects the transport: udp or websocket.

public const string TransportArg = "-transport"

Field Value

string

Methods

Apply(NetConfig, IReadOnlyList<string>)

Applies every recognised argument in args to config, in order (a later repeat wins). The first element is not skipped, so pass the arguments without the program path or with it; a path is never mistaken for an argument.

public static NetCommandLineResult Apply(NetConfig config, IReadOnlyList<string> args)

Parameters

config NetConfig
args IReadOnlyList<string>

Returns

NetCommandLineResult

Exceptions

ArgumentNullException

config or args is null.

IsHeadless(IReadOnlyList<string>)

True when the arguments contain Unity's -batchmode or -nographics switch.

public static bool IsHeadless(IReadOnlyList<string> args)

Parameters

args IReadOnlyList<string>

Returns

bool

Exceptions

ArgumentNullException

args is null.

TryParseJoinCodes(string, out JoinCodeProvider)

Parses auto, none (or off), relay or rendezvous (ignoring case).

public static bool TryParseJoinCodes(string text, out JoinCodeProvider provider)

Parameters

text string
provider JoinCodeProvider

Returns

bool

TryParseTopology(string, out Topology)

Parses host, server or client (ignoring case).

public static bool TryParseTopology(string text, out Topology topology)

Parameters

text string
topology Topology

Returns

bool

TryParseTransport(string, out TransportKind)

Parses udp, websocket or ws (ignoring case).

public static bool TryParseTransport(string text, out TransportKind transport)

Parameters

text string
transport TransportKind

Returns

bool