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):
-mode | host, server or client (Topology). |
-address / -ip | Server address to join, or local address to bind (Address). |
-port | 1-65535 (Port). |
-transport | udp, or websocket / ws (Transport). |
-tickrate | Ticks per second (TickRate). |
-maxplayers | Player cap (MaxPlayers). |
-name | The server's name (ServerName). |
-password | The server password (Password); MINDATTIC_SERVER_PASSWORD is safer, since a command line is visible to other processes. |
-joincodes | auto, none, relay or rendezvous (JoinCodes). |
-rendezvous | Rendezvous service base URL (RendezvousUrl). |
-rendezvoussecret | Its registration secret (RendezvousSecret); the environment variable is safer, since a command line is visible to other processes. |
-publicaddress | Address players reach this server at (PublicAddress). |
-publicport | Port players reach this server at (PublicPort). |
-netsim | Simulated network conditions: none, broadband, mobile4g, mobile3g, lossy or custom (Conditions). |
-bot | Launches 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 / -loss | Simulated 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
BatchModeArg
Unity's batch-mode switch; its presence marks a headless run.
public const string BatchModeArg = "-batchmode"
Field Value
BotArg
Launches a bot client playing the given role (BotArg).
public const string BotArg = "-bot"
Field Value
IpArg
Alias of AddressArg, matching Unity Transport's own -ip.
public const string IpArg = "-ip"
Field Value
JitterArg
Sets the simulated jitter in milliseconds (custom conditions).
public const string JitterArg = "-jitter"
Field Value
JoinCodesArg
Selects the join-code provider: auto, none, relay or rendezvous.
public const string JoinCodesArg = "-joincodes"
Field Value
LatencyArg
Sets the simulated latency in milliseconds (custom conditions).
public const string LatencyArg = "-latency"
Field Value
LossArg
Sets the simulated packet loss in percent (custom conditions).
public const string LossArg = "-loss"
Field Value
MaxPlayersArg
Selects the player cap.
public const string MaxPlayersArg = "-maxplayers"
Field Value
ModeArg
Selects the topology: host, server or client.
public const string ModeArg = "-mode"
Field Value
NameArg
Sets the server's name.
public const string NameArg = "-name"
Field Value
NetSimArg
Selects the simulated network conditions profile.
public const string NetSimArg = "-netsim"
Field Value
NoGraphicsArg
Unity's no-graphics switch; its presence marks a headless run.
public const string NoGraphicsArg = "-nographics"
Field Value
PasswordArg
Sets the server password.
public const string PasswordArg = "-password"
Field Value
PortArg
Selects the port.
public const string PortArg = "-port"
Field Value
PublicAddressArg
Sets the address players reach this server at.
public const string PublicAddressArg = "-publicaddress"
Field Value
PublicPortArg
Sets the port players reach this server at.
public const string PublicPortArg = "-publicport"
Field Value
RendezvousArg
Sets the rendezvous service URL.
public const string RendezvousArg = "-rendezvous"
Field Value
RendezvousSecretArg
Sets the rendezvous registration secret.
public const string RendezvousSecretArg = "-rendezvoussecret"
Field Value
TickRateArg
Selects the tick rate.
public const string TickRateArg = "-tickrate"
Field Value
TransportArg
Selects the transport: udp or websocket.
public const string TransportArg = "-transport"
Field Value
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
configNetConfigargsIReadOnlyList<string>
Returns
Exceptions
- ArgumentNullException
configorargsis null.
IsHeadless(IReadOnlyList<string>)
True when the arguments contain Unity's -batchmode or -nographics switch.
public static bool IsHeadless(IReadOnlyList<string> args)
Parameters
argsIReadOnlyList<string>
Returns
Exceptions
- ArgumentNullException
argsis 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
textstringproviderJoinCodeProvider
Returns
TryParseTopology(string, out Topology)
Parses host, server or client (ignoring case).
public static bool TryParseTopology(string text, out Topology topology)
Parameters
Returns
TryParseTransport(string, out TransportKind)
Parses udp, websocket or ws (ignoring case).
public static bool TryParseTransport(string text, out TransportKind transport)
Parameters
textstringtransportTransportKind