Skip to content

Commit ba38de3

Browse files
Merge branch 'develop-2.0.0' into modify-release-automation-schedule
2 parents bd41900 + 6eb88aa commit ba38de3

File tree

54 files changed

+1358
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1358
-186
lines changed

.yamato/_triggers.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ pr_code_changes_checks:
8787
# Coverage on other standalone machines is present in Nightly job so it's enough to not run all of them for PRs
8888
# desktop_standalone_test and cmb_service_standalone_test are both reusing desktop_standalone_build dependency so we run those in the same configuration on PRs to reduce waiting time.
8989
# Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations
90-
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_trunk
91-
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_trunk
90+
91+
# TODO: Move these tests back to trunk once CMB Service has addressed https://jira.unity3d.com/browse/MTTB-1680
92+
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_6000.4
93+
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_6000.4
9294
triggers:
9395
expression: |-
9496
(pull_request.comment eq "ngo" OR

.yamato/cmb-service-standalone-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cmb_service_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}
5454

5555
commands:
5656
# run_cmb_service.sh builds and starts a release version of the full CMB service (along with the limited echo server)
57-
- ./Tools/CI/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT
57+
- ./Tools/CI/service.cmb/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT
5858

5959
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models
6060
- UnifiedTestRunner --suite=playmode --player-load-path=build/players --artifacts-path=test-results --testproject={{ project.path }} --editor-location=.Editor --playergraphicsapi=Null --fail-on-assert --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}

.yamato/project.metafile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ validation_editors:
162162
- 6000.0
163163
- 6000.2
164164
- 6000.3
165+
- 6000.4
165166
- trunk
166167
minimal:
167168
- 6000.0

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Netcode for GameObjects
22

3-
[![Forums](https://img.shields.io/badge/unity--forums-multiplayer-blue)](https://forum.unity.com/forums/multiplayer.26/) [![Discord](https://img.shields.io/discord/449263083769036810.svg?label=discord&logo=discord&color=informational)](https://discord.gg/FM8SE9E)
4-
[![Manual](https://img.shields.io/badge/docs-manual-informational.svg)](https://docs-multiplayer.unity3d.com/netcode/current/about) [![API](https://img.shields.io/badge/docs-api-informational.svg)](https://docs-multiplayer.unity3d.com/netcode/current/api/introduction)
3+
[![Forums](https://img.shields.io/badge/unity--forums-multiplayer-blue)](https://discussions.unity.com/tag/Netcode-for-GameObjects) [![Discord](https://img.shields.io/discord/449263083769036810.svg?label=discord&logo=discord&color=informational)](https://discord.gg/unity)
4+
[![Manual](https://img.shields.io/badge/docs-manual-informational.svg)](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest) [![API](https://img.shields.io/badge/docs-api-informational.svg)](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest/?subfolder=/api/Unity.Netcode.NetworkManager.html)
55

66
[![GitHub Release](https://img.shields.io/github/release/Unity-Technologies/com.unity.netcode.gameobjects.svg?logo=github)](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/releases/latest)
77

88
### Welcome!
99

1010
Welcome to the Netcode for GameObjects repository.
1111

12-
Netcode for GameObjects is a Unity package that provides networking capabilities to GameObject & MonoBehaviour workflows. The framework is interoperable with many low-level transports, including the official [Unity Transport Package](https://docs-multiplayer.unity3d.com/transport/current/about).
12+
Netcode for GameObjects is a Unity package that provides networking capabilities to GameObject & MonoBehaviour workflows. The framework is interoperable with many low-level transports, including the official [Unity Transport Package](https://docs.unity3d.com/Packages/com.unity.transport@latest).
1313

1414
### Getting Started
1515

16-
Visit the [Multiplayer Docs Site](https://docs-multiplayer.unity3d.com/) for package & API documentation, as well as information about several samples which leverage the Netcode for GameObjects package.
16+
Visit the [Multiplayer Docs Site](https://docs.unity3d.com/Manual/multiplayer.html) for package & API documentation, as well as information about several samples which leverage the Netcode for GameObjects package.
1717

18-
You can also jump right into our [Hello World](https://docs-multiplayer.unity3d.com/netcode/current/tutorials/helloworld) guide for a taste of how to use the framework for basic networked tasks.
18+
You can also use our [quickstart guide](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest/?subfolder=/manual/tutorials/get-started-with-ngo.html) to get a taste of how to use the framework for basic networked tasks.
1919

2020
### Community and Feedback
2121

22-
For general questions, networking advice or discussions about Netcode for GameObjects, please join our [Discord Community](https://discord.gg/FM8SE9E) or create a post in the [Unity Multiplayer Forum](https://forum.unity.com/forums/multiplayer.26/).
22+
For general questions, networking advice or discussions about Netcode for GameObjects, please join our [Discord Community](https://discord.gg/unity) or create a post in the [Unity Forum's "Netcode for GameObjects" section](https://discussions.unity.com/tag/Netcode-for-GameObjects).
2323

2424
### Compatibility
2525

@@ -48,4 +48,4 @@ We are an open-source project and we encourage and welcome contributions. If you
4848

4949
If you have an issue, bug or feature request, please follow the information in our [contribution guidelines](CONTRIBUTING.md) to submit an issue.
5050

51-
You can also check out our public [roadmap](https://unity.com/roadmap/unity-platform/multiplayer-networking) to get an idea for what we might be working on next!
51+
You can also check out our public [roadmap](https://unity.com/roadmap#unity-platform-multiplayer) to get an idea for what we might be working on next!

Tools/CI/service.cmb/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Testing against the CMB Service
2+
3+
The CMB Service is a tool that is external to our repository. The tool is inside the `runtime` folder in the [mps-common-multiplayer-backend](https://github.com/Unity-Technologies/mps-common-multiplayer-backend) repository.
4+
5+
Due to this, there is some more setup needed when running tests against the CMB Service.
6+
7+
## Configuration
8+
9+
The tests are automatically configured to run any `HostOrServer.DAHost` or `NetworkTopologyTypes.DistributedAuthority` test against the CMB server when either the `USE_CMB_SERVICE` scripting define is set, or when an environment variable is passed in with `USE_CMB_SERVICE=true`. When set, all non-distributed authority compatible tests will be ignored.
10+
11+
By default, the tests are configured to look for the service on the local machine (`localhost`/`http://127.0.0.1`) at port `7789`.
12+
13+
## Running against the service
14+
15+
First, ensure the `USE_CMB_SERVICE` scripting define or environment variable is set.
16+
17+
### Download the service
18+
19+
Go to the `CMB Runtime CI` action inside the cmb repo ([link here](https://github.com/Unity-Technologies/mps-common-multiplayer-backend/actions/workflows/runtime.yaml)). Open the most recent job and scroll down to the bottom of the page (You may have to scroll in the sidebar on the left, the centre of the page is not scrollable).
20+
21+
Inside the **Artifacts** section at the bottom of the page, download the `comb-server-<platform>-latest` that matches your computer architecture. This will download a pre-built binary of the most recent CMB Service.
22+
23+
### Run the service locally
24+
25+
Next we'll run the binary on the command line.
26+
27+
> [!NOTE]
28+
> If you're running on macOS, you'll have to add execution privileges to the binary before running it.
29+
30+
```bash
31+
xattr -c /path/to/comb-server
32+
```
33+
34+
To run the service, run the following command:
35+
36+
```bash
37+
/path/to/download/comb-server -l info --metrics-port 5000 standalone --port 7789 -t 60m
38+
```
39+
40+
Note that we have set the port to `7789` to match where the tests will be looking.
41+
42+
After each test, all connected clients will disconnect from the service. The service will automatically shut down when that happens. When running multiple tests in a row, it can be more convenient to run the service in a loop:
43+
44+
```bash
45+
while :; do /path/to/download/file -l info --metrics-port 5000 standalone --port 7789 -t 60m; done
46+
```
47+
48+
### Run the tests
49+
50+
With `USE_CMB_SERVICE` set, everything should be configured so that running any distributed authority test in the editor should run against the service we have running on the command line. Try running a test to validate that information is logged in the command line.
51+
52+
## Further configuration
53+
54+
The following environment variables allow for further configuration of the setup.
55+
56+
`CMB_SERVICE_PORT` defines the port where the tests will try to connect to the service (defaults to `7789`).
57+
58+
`NGO_HOST` defines the http address where the tests will try to connect to the service (defaults to `127.0.0.1`).
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ logError(){
9191

9292
# Protocol Buffer Compiler ------------------------------------------------------
9393

94-
# Apply any updates
94+
# Apply any updates
9595
logMessage "Updating modules..."
9696
sudo apt-get update
9797

9898
# Install Protocol Buffer Compiler (using apt-get)
99-
logMessage "Installing protocol bufffer compiler as SUDO..."
99+
logMessage "Installing protocol buffer compiler as SUDO..."
100100
try sudo apt-get install -y protobuf-compiler
101101

102102
# If the previous command failed, try without sudo
103103
if $ThrewError; then
104-
logMessage "Installing protocol bufffer compiler as shell assigned account..."
104+
logMessage "Installing protocol buffer compiler as shell assigned account..."
105105
apt-get install -y protobuf-compiler
106106
else
107-
logMessage "Protocol bufffer compiler was installed as sudo!"
107+
logMessage "Protocol buffer compiler was installed as sudo!"
108108
fi
109109

110110
# Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
- `RpcInvokePermission` to control who has permission to invoke specific RPC methods. (#3731)
1314
- Added NetworkRigidbody documentation section. (#3664)
15+
- Added new fields to the `SceneMap` struct when using Unity 6.3 or higher. These fields allow referencing scene handles via the new `SceneHandle` struct. (#3734)
1416

1517
### Changed
1618

19+
- Better error message when using generic IEquatable in a generic INetworkSerializable class and updated documentation with workaround. (#3739)
1720
- The `NetworkManager` functions `GetTransportIdFromClientId` and `GetClientIdFromTransportId` will now return `ulong.MaxValue` when the clientId or transportId do not exist. (#3707)
1821
- Changed NetworkShow to send a message at the end of the frame and force a NetworkVariable synchronization prior to generating the CreateObjectMessage as opposed to waiting until the next network tick to synchronize the show with the update to NetworkVariables. (#3664)
1922
- Changed NetworkTransform now synchronizes `NetworkTransform.SwitchTransformSpaceWhenParented` when it is updated by the motion model authority. (#3664)
@@ -24,16 +27,18 @@ Additional documentation and release notes are available at [Multiplayer Documen
2427

2528
### Deprecated
2629

30+
- Deprecated all `RequireOwnership` fields around the RPCs in favor of the `RpcInvokePermission`. (#3731)
31+
- On Unity 6.5 some `SceneMap` fields that use an `int` to represent a `SceneHandle` are deprecated. (#3734)
2732

2833
### Removed
2934

30-
3135
### Fixed
3236

3337
- Multiple disconnect events from the same transport will no longer disconnect the host. (#3707)
3438
- Fixed NetworkTransform state synchronization issue when `NetworkTransform.SwitchTransformSpaceWhenParented` is enabled and the associated NetworkObject is parented multiple times in a single frame or within a couple of frames. (#3664)
3539
- Fixed issue when spawning, parenting, and immediately re-parenting when `NetworkTransform.SwitchTransformSpaceWhenParented` is enabled. (#3664)
3640
- Fixed issue where the disconnect event and provided message was too generic to know why the disconnect occurred. (#3551)
41+
- Exception when the network prefab list in the network manager has uninitialized elements. (#3739)
3742

3843
### Security
3944

com.unity.netcode.gameobjects/Documentation~/advanced-topics/message-system/rpc.md

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

3-
Any process can communicate with any other process by sending a remote procedure call (RPC). As of Netcode for GameObjects version 1.8.0, the `Rpc` attribute encompasses server to client RPCs, client to server RPCs, and client to client RPCs.
3+
Any process can communicate with any other process by sending a remote procedure call (RPC). The `Rpc` attribute is the recommended attribute to use when declaring RPC methods. The `Rpc` attribute's parameters define the receivers and execution rights for the RPC method.
44

55
![](../../images/sequence_diagrams/RPCs/ServerRPCs.png)
66

@@ -204,7 +204,7 @@ There are a few other parameters that can be passed to either the `Rpc` attribut
204204
| Parameter | Description |
205205
| ----------------------- | ------------------------------------------------------------ |
206206
| `Delivery` | Controls whether the delivery is reliable (default) or unreliable.<br /><br />Options: `RpcDelivery.Reliable` or `RpcDelivery.Unreliable`<br />Default: `RpcDelivery.Reliable` |
207-
| `RequireOwnership` | If `true`, this RPC throws an exception if invoked by a player that does not own the object. This is in effect for server-to-client, client-to-server, and client-to-client RPCs - i.e., a server-to-client RPC will still fail if the server is not the object's owner.<br /><br />Default: `false` |
207+
| `InvokePermission` | Sets an RPC's invocation permissions.<br /><br />Options:<br /> `RpcInvokePermission.Server` - This RPC throws an exception if invoked by a game client that is not the server.<br />`RpcInvokePermission.Owner` - This RPC throws an exception if invoked by a game client that does not own the object.<br />`RpcInvokePermission.Everyone` - This can be invoked by any connected game client.<br />Default: `RpcInvokePermission.Everyone` |
208208
| `DeferLocal` | If `true`, RPCs that execute locally will be deferred until the start of the next frame, as if they had been sent over the network. (They will not actually be sent over the network, but will be treated as if they were.) This is useful for mutually recursive RPCs on hosts, where sending back and forth between the server and the "host client" will cause a stack overflow if each RPC is executed instantly; simulating the flow of RPCs between remote client and server enables this flow to work the same in both contexts.<br /><br />Default: `false` |
209209
| `AllowTargetOverride` | By default, any `SendTo` value other than `SendTo.SpecifiedInParams` is a hard-coded value that cannot be changed. Setting this to `true` allows you to provide an alternate target at runtime, while using the `SendTo` value as a fallback if no runtime value is provided. |
210210

@@ -215,6 +215,116 @@ There are a few other parameters that can be passed to either the `Rpc` attribut
215215
| `Target` | Runtime override destination for the RPC. (See above for more details.) Populating this value will throw an exception unless either the `SendTo` value for the RPC is `SendTo.SpecifiedInParams`, or `AllowTargetOverride` is `true`.<br /><br />Default: `null` |
216216
| `LocalDeferMode` | Overrides the `DeferLocal` value. `DeferLocalMode.Defer` causes this particular invocation of this RPC to be deferred until the next frame even if `DeferLocal` is `false`, while `DeferLocalMode.SendImmediate` causes the RPC to be executed immediately on the local machine even if `DeferLocal` is `true`. `DeferLocalMode.Default` does whatever the `DeferLocal` value in the attribute is configured to do.<br /><br />Options: `DeferLocalMode.Default`, `DeferLocalMode.Defer`, `DeferLocalMode.SendImmediate`<br />Default: `DeferLocalMode.Default` |
217217

218+
## Invocation order
219+
220+
Rpc message sent with `RpcDelivery.Reliable` will be sent and invoked on other game clients in the same order as they were called on the local game client.
221+
222+
```csharp
223+
[Rpc(SendTo.Server)]
224+
public void OpenDoorRpc(int doorId, RpcParams rpcParams)
225+
{
226+
Debug.Log($"client {rpcParams.Receive.SenderClientId} has opened door {doorId}");
227+
228+
// Server can handle door opening here
229+
}
230+
231+
[Rpc(SendTo.Server)]
232+
void OpenChestRPC(int chestId, RpcParams rpcParams)
233+
{
234+
Debug.Log($"client {rpcParams.Receive.SenderClientId} has opened chest {chestId}");
235+
236+
// Server can handle door opening here
237+
}
238+
239+
void Update()
240+
{
241+
if (IsClient && Input.GetKeyDown(KeyCode.O))
242+
{
243+
OpenDoorRpc(1)
244+
OpenDoorRpc(2)
245+
OpenChestRpc(5)
246+
}
247+
248+
// Other clients will log:
249+
//
250+
// "client 1 has opened door 1"
251+
// "client 1 has opened door 2"
252+
// "client 1 has opened chest 5"
253+
}
254+
```
255+
256+
> [!Warning]
257+
> Invocation order is not guaranteed with nested RPC invocations that include targets that may invoke locally. Invocation order is also not guaranteed when using `RpcDelivery.Unreliable`
258+
259+
### Deferring local invocation
260+
261+
Invoking an RPC from within another RPC introduces the risk that the local RPC may invoke before messages are sent to other game clients. This will result in the RPC message for the inner RPC invocation being sent before the message for the outer RPC.
262+
263+
```csharp
264+
[Rpc(SendTo.Everyone)]
265+
public void TryOpenDoorRpc(int doorId, RpcParams rpcParams)
266+
{
267+
Debug.Log($"client {rpcParams.Receive.SenderClientId} is trying to open door {doorId}");
268+
269+
if (HasAuthority) {
270+
// Authority handles opening the door here
271+
272+
// If the authority is invoking TryOpenDoorRpc locally before the authority has sent TryOpenDoorRpc to other clients, OpenDoorRpc will be sent before TryOpenDoorRpc.
273+
OpenDoorRpc(doorId);
274+
}
275+
}
276+
277+
[Rpc(SendTo.Everyone)]
278+
public void OpenDoorRpc(int doorId, RpcParams rpcParams)
279+
{
280+
Debug.Log($"client {rpcParams.Receive.SenderClientId} marked door {doorId} as open");
281+
}
282+
283+
void Update()
284+
{
285+
if (Input.GetKeyDown(KeyCode.O))
286+
{
287+
// Invocation of TryOpenDoorRpc and OpenDoorRpc may be inverted depending on the context in which TryOpenDoorRpc is invoked
288+
TryOpenDoorRpc(20);
289+
}
290+
}
291+
```
292+
293+
Use the RPC `LocalDeferMode` to resolve issue. Configuring the RPC to be deferred when invoked locally will ensure that any outer RPC messages are always sent before the inner function is invoked.
294+
295+
```csharp
296+
// An RPC can be configured to defer the local invocation in the attribute definition
297+
[Rpc(SendTo.Everyone, DeferLocal = true)]
298+
public void TryOpenDoorRpc(int doorId, RpcParams rpcParams = default)
299+
{
300+
Debug.Log($"client {rpcParams.Receive.SenderClientId} is trying to open door {doorId}");
301+
302+
if (HasAuthority) {
303+
304+
// Authority handles opening the door here
305+
306+
// Defer mode can also be passed in at the call site.
307+
OpenDoorRpc(doorId, LocalDeferMode.Defer);
308+
}
309+
}
310+
311+
[Rpc(SendTo.Everyone)]
312+
public void OpenDoorRpc(int doorId, RpcParams rpcParams = default)
313+
{
314+
Debug.Log($"client {rpcParams.Receive.SenderClientId} marked door {doorId} as open");
315+
}
316+
317+
void Update()
318+
{
319+
if (Input.GetKeyDown(KeyCode.O))
320+
{
321+
// TryOpenDoorRpc is defined with DeferLocal
322+
// DeferLocal ensures that RPC messages are sent to all other targets before the RPC is invoked locally
323+
TryOpenDoorRpc(20);
324+
}
325+
}
326+
```
327+
218328
## Additional resources
219329

220330
* [RPC parameters](rpc-params.md)

0 commit comments

Comments
 (0)