Skip to content

Commit bb1bee7

Browse files
committed
Move outdated docs code to docs tests and update some docs
1 parent a3c152f commit bb1bee7

4 files changed

Lines changed: 63 additions & 30 deletions

File tree

‎com.unity.netcode.gameobjects/Documentation~/advanced-topics/transports.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Transports
22

3-
Unity Netcode for GameObjects (Netcode) uses Unity Transport by default and supports UNet Transport (deprecated) up to Unity 2022.2 version.
3+
Unity Netcode for GameObjects (Netcode) uses Unity Transport by default and also provides a single player transport.
44

55
## So what is a transport layer?
66

@@ -18,11 +18,13 @@ A transport layer can provide:
1818

1919
Netcode's default transport Unity Transport is an entire transport layer that you can use to add multiplayer and network features to your project with or without Netcode. Refer to the Transport [documentation](https://docs.unity3d.com/Packages/com.unity.transport@latest) for more information and how to [install](https://docs.unity3d.com/Packages/com.unity.transport@latest?subfolder=/manual/install.html).
2020

21-
## Unity's UNet Transport Layer API
21+
Netcode provides a [UnityTransport](xref:Unity.Netcode.Transports.UTP.UnityTransport) implementation for easy transport integration with Netcode.
2222

23-
UNet is a deprecated solution that is no longer supported after Unity 2022.2. Unity Transport Package is the default transport for Netcode for GameObjects. We recommend transitioning to Unity Transport as soon as possible.
23+
## Single player transport
2424

25-
### Community Transports or Writing Your Own
25+
Netcode also provides a [single player transport](./singleplayer.md) that allows for easy switching between multiplayer and single player configurations.
26+
27+
## Community Transports or Writing Your Own
2628

2729
You can use any of the community contributed custom transport implementations or write your own.
2830

‎com.unity.netcode.gameobjects/Documentation~/command-line-arguments.md‎

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,22 @@ You can define additional custom command-line arguments and retrieve them throug
2323
## Example
2424

2525
The following code shows you an example of defining and then reading a custom command-line argument.
26-
```
27-
private const string k_OverrideArg = "-argName";
28-
29-
private bool ParseCommandLineOptions(out string command)
30-
{
31-
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-
```
26+
27+
[!code-cs[](../Tests/Runtime/DocumentationCodeSamples/Configuration/CommandLineOptionsDocsTests.cs#DefineAndRead)]
4028

4129
Usage example:
4230

43-
```
44-
if (ParseCommandLineOptions(out var command))
45-
{
46-
// Your logic here
47-
}
48-
```
31+
[!code-cs[](../Tests/Runtime/DocumentationCodeSamples/Configuration/CommandLineOptionsDocsTests.cs#Usage)]
4932

5033
## Override connection data
5134

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:
35+
By default, the command line provided connection port and ip address take precedence over runtime configured values when using the [Unity transport](./advanced-topics/transports.md#unity-transport-package).
5336

54-
```
55-
UnityTransport.SetConnectionData(string ip, ushort port, string listenAddress, bool forceOverride);
56-
```
37+
> [!NOTE]
38+
> When the [Unity dedicated server package](https://docs.unity3d.com/Documentation/Manual/dedicated-server.html) is installed, Unity transport will use the port and ip address provided by the dedicated server package.
5739
58-
Setting `forceOverride` to `true` ensures that the values you pass to `SetConnectionData` override any values specified via command-line arguments.
40+
If you want to ignore the connection port provided through command-line arguments, you can override it by setting the `forceOverrideCommandLineArgs` parameter of UnityTransport's [`SetConnectionData`](xref:Unity.Netcode.Transports.UTP.UnityTransport.SetConnectionData(System.Boolean,System.String,System.UInt16,System.String)). Setting `forceOverrideCommandLineArgs` to `true` ensures that the values you pass to `SetConnectionData` will override any values specified via command-line arguments.
5941

6042
## Additional resources
6143

62-
- [Command-line arguments in the Unity Manual](https://docs.unity3d.com/6000.2/Documentation/Manual/CommandLineArguments.html)
44+
- [Command-line arguments in the Unity Manual](https://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using NUnit.Framework;
2+
using Unity.Netcode;
3+
4+
namespace DocumentationCodeSamples
5+
{
6+
internal class CommandLineOptionsDocsTests
7+
{
8+
#region DefineAndRead
9+
private const string k_OverrideArg = "-argName";
10+
11+
private bool ParseCommandLineOptions(out string command)
12+
{
13+
if (CommandLineOptions.TryGetArg(k_OverrideArg, out var argValue))
14+
{
15+
command = argValue;
16+
return true;
17+
}
18+
command = default;
19+
return false;
20+
}
21+
#endregion
22+
23+
private string CommandLineUsage()
24+
{
25+
#region Usage
26+
if (ParseCommandLineOptions(out var command))
27+
{
28+
// Your logic here
29+
}
30+
#endregion
31+
32+
return command;
33+
}
34+
35+
[Test]
36+
public void TestCommandLineUsage()
37+
{
38+
// This is a compile test.
39+
var succeeded = ParseCommandLineOptions(out var command);
40+
Assert.NotNull(succeeded);
41+
42+
var output = CommandLineUsage();
43+
Assert.AreEqual(command, output);
44+
}
45+
}
46+
}

‎com.unity.netcode.gameobjects/Tests/Runtime/DocumentationCodeSamples/Configuration/CommandLineOptionsDocsTests.cs.meta‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)