You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
11
11
### Added
12
12
13
13
- It is now possible to control which port clients will bind to using the `UnityTransport.ConnectionData.ClientBindPort` field. If not set, clients will bind to an ephemeral port (same as before this change). (#3764)
14
-
14
+
- Added a flag to override command-line arguments (port and ip) in `SetConnectionData`. (#3760)
15
+
- Added a command-line singleton to parse environment command-line arguments. (#3760)
15
16
16
17
### Changed
17
18
@@ -25,11 +26,12 @@ Additional documentation and release notes are available at [Multiplayer Documen
25
26
26
27
### Fixed
27
28
29
+
- Fixed issues with the "Client-server quickstart for Netcode for GameObjects" script having static methods and properties. (#3787)
28
30
- Fixed issue where a warning message was being logged upon a client disconnecting from a server when the log level is set to developer. (#3786)
29
31
- Fixed issue where the server or host would no longer have access to the transport id to client id table when processing a transport level client disconnect event. (#3786)
30
32
- Fixed issue where invoking an RPC, on another `NetworkBehaviour` associated with the same `NetworkObject` that is ordered before the `NetworkBehaviour` invoking the RPC, during `OnNetworkSpawn` could throw an exception if scene management is disabled. (#3782)
31
33
- Fixed issue where the `Axis to Synchronize` toggles didn't work with multi object editing in `NetworkTransform`. (#3781)
32
-
34
+
- Fixed issue where using the dedicated server package would override all attempts to change the port by code. (#3760)
Use [command-line arguments](https://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html) to configure certain aspects of your game at launch. This is especially useful for dedicated server builds, where arguments let you override default network settings such as the IP address and port.
4
+
5
+
## Using command-line arguments
6
+
7
+
When launching a standalone build (such as a headless dedicated server), you can supply custom arguments to modify runtime behavior.
8
+
9
+
Reserved arguments:
10
+
11
+
-`-port`
12
+
-`-ip`
13
+
14
+
Unity provides built-in parsing for standard arguments, and you can extend this behavior by adding your own.
15
+
16
+
## Custom arguments
17
+
18
+
You can define additional custom command-line arguments and retrieve them through the `CommandLineOptions` class. Use `GetArgs()` in your project code to collect and process these values.
19
+
20
+
> [!NOTE]
21
+
> Adding a custom command-line argument requires you to explicitly retrieve and handle it in your implementation.
22
+
23
+
## Example
24
+
25
+
The following code shows you an example of defining and then reading a custom command-line argument.
if (CommandLineOptions.Instance.GetArg(k_OverrideArg) is string argValue)
32
+
{
33
+
command = argValue;
34
+
return true;
35
+
}
36
+
command = default;
37
+
return false;
38
+
}
39
+
```
40
+
41
+
Usage example:
42
+
43
+
```
44
+
if (ParseCommandLineOptions(out var command))
45
+
{
46
+
// Your logic here
47
+
}
48
+
```
49
+
50
+
## Override connection data
51
+
52
+
If you want to ignore the connection port provided through command-line arguments, you can override it by using the optional `forceOverride` parameter in:
|**[Configuring connections](configure-connections.md)**| Configure connections in your project. |
8
-
|**[Transports](advanced-topics/transports.md)**| Transport layers establish communication between your application and different hosts in a network. |
9
-
|**[Unity Relay](relay/relay.md)**| Use Unity Relay with Netcode for GameObjects to connect clients and hosts over the internet using a relay server. |
|**[Configuring connections](configure-connections.md)**| Configure connections in your project. |
9
+
|**[Transports](advanced-topics/transports.md)**| Transport layers establish communication between your application and different hosts in a network. |
10
+
|**[Unity Relay](relay/relay.md)**| Use Unity Relay with Netcode for GameObjects to connect clients and hosts over the internet using a relay server. |
11
+
|**[Command-line arguments](command-line-arguments.md)**| Use command-line arguments to configure certain aspects of your game at launch. |
@@ -215,14 +219,14 @@ In your Hello World project, you created a NetworkManager by adding the pre-crea
215
219
The `HelloWorldManager.cs` script accomplishes this menu within the `StartButtons().` After you select a button, the `StatusLabels()`method adds a label on-screen to display which mode you have selected. This helps distinguish Game view windows from each other when testing your multiplayer game.
216
220
217
221
```csharp
218
-
staticvoidStartButtons()
222
+
privatevoidStartButtons()
219
223
{
220
224
if (GUILayout.Button("Host")) NetworkManager.Singleton.StartHost();
221
225
if (GUILayout.Button("Client")) NetworkManager.Singleton.StartClient();
222
226
if (GUILayout.Button("Server")) NetworkManager.Singleton.StartServer();
@@ -470,7 +474,7 @@ The `Rpc` sets the position NetworkVariable on the server's instance of the play
470
474
The server instance of the player modifies the `Position``NetworkVariable` through the `Rpc`. If the player is a client, it must apply the position locally inside the `Update` loop. (Since the two values are the same on the server, the server can run the same logic with no side effects, but you could also add `if(IsClient)` here.)
471
475
472
476
```csharp
473
-
voidUpdate()
477
+
privatevoidUpdate()
474
478
{
475
479
transform.position=Position.Value;
476
480
}
@@ -479,7 +483,7 @@ The server instance of the player modifies the `Position` `NetworkVariable` thro
479
483
Because the `HelloWorldPlayer.cs` script handles the position NetworkVariable, the `HelloWorldManager.cs` script can define the contents of `SubmitNewPosition()`.
480
484
481
485
```csharp
482
-
staticvoidSubmitNewPosition()
486
+
privatevoidSubmitNewPosition()
483
487
{
484
488
if (GUILayout.Button(NetworkManager.Singleton.IsServer?"Move":"Request Position Change"))
0 commit comments