Skip to content

Commit 9912018

Browse files
Merge branch 'develop-2.0.0' into standards-check-update
2 parents 428383c + 46743e4 commit 9912018

83 files changed

Lines changed: 1376 additions & 984 deletions

File tree

Some content is hidden

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

.yamato/_triggers.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ pr_code_changes_checks:
8989
# Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations
9090
- .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_{{ pinnedTrunk }}
9191
- .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_{{ pinnedTrunk }}
92-
# Run code coverage test
93-
- .yamato/code-coverage.yml#code_coverage_ubuntu_{{ validation_editors.default }}
92+
# Run code coverage test (PRs use the pinned "safe" trunk)
93+
- .yamato/code-coverage.yml#code_coverage_project_test_testproject_ubuntu_{{ pinnedTrunk }}
9494
triggers:
9595
expression: |-
9696
(pull_request.comment eq "ngo" OR
@@ -159,8 +159,8 @@ develop_nightly:
159159
- .yamato/project-updated-dependencies-test.yml#updated-dependencies_testproject_NGO_win_6000.0
160160
# Run API validation to early-detect all new APIs that would force us to release new minor version of the package. Note that for this to work the package version in package.json must correspond to "actual package state" which means that it should be higher than last released version
161161
- .yamato/vetting-test.yml#vetting_test
162-
# Run code coverage test
163-
- .yamato/code-coverage.yml#code_coverage_ubuntu_{{ validation_editors.default }}
162+
# Run code coverage test (nightly uses actual trunk)
163+
- .yamato/code-coverage.yml#code_coverage_project_test_testproject_ubuntu_trunk
164164

165165

166166
# Run all tests on weekly bases

.yamato/code-coverage.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,37 @@
22
---
33

44
# DESCRIPTION--------------------------------------------------------------------------
5-
# This job is responsible for executing package tests with code coverage analysis enabled.
5+
# This job runs the in-repo testproject tests with code coverage analysis enabled.
6+
# The project tests also exercise the NGO package tests, so a separate package-test coverage job is not needed.
67
# Coverage analysis provides insights into:
78
# Test coverage metrics for NGO assemblies
89
# Line and branch coverage statistics
910
# Generated HTML reports for coverage visualization
1011
# Additional metrics for coverage analysis
1112

1213
# CONFIGURATION STRUCTURE--------------------------------------------------------------
13-
# Jobs are generated using nested loops through:
14-
# 1. For default platform only (Ubuntu) since coverage would not vary between platforms (no need for checks on more platforms)
15-
# 2. For default editor version (trunk) since coverage would not vary between editors (no need for checks on more editors)
14+
# Jobs are generated for:
15+
# 1. Default platform only (Ubuntu) since coverage would not vary between platforms (no need for checks on more platforms)
16+
# 2. Two editors: actual "trunk" (used by nightly) and the "pinnedTrunk" safe version (used by PRs).
17+
# Occasionally trunk breaks our tests, so PRs run against a pinned "safe" trunk while nightly runs actual trunk.
1618

1719
#TECHNICAL CONSIDERATIONS---------------------------------------------------------------
18-
# In theory this job also runs package tests, but we don't want to use it as default since is heavier (because of added coverage analysis) and coverage is not changing that often
1920
# Requires Unity Editor installation
2021
# Burst compilation is disabled to ensure accurate coverage measurement
2122
# In order to properly use -coverage-results-path parameter we need to start it with $PWD (which means the absolute path). Otherwise coverage results will not be visible
2223

2324
# QUALITY CONSIDERATIONS--------------------------------------------------------------------
24-
# To see where this job is included (in trigger job definitions) look into _triggers.yml file
25-
25+
# To see where this job is included (in trigger job definitions) look into _triggers.yml file. Currently:
26+
# [Code Coverage] Project Test runs on PR changes (pr_code_changes_checks, pinnedTrunk) and nightly (develop_nightly, trunk)
2627

28+
{% assign coverage_editors = "trunk," | append: pinnedTrunk | split: "," -%}
2729

2830
{% for platform in test_platforms.default -%}
29-
{% for editor in validation_editors.default -%}
30-
code_coverage_{{ platform.name }}_{{ editor }}:
31-
name: Code Coverage - NGO [{{ platform.name }}, {{ editor }}]
31+
{% for project in projects.default -%}
32+
{% for editor in coverage_editors -%}
33+
{% if editor == "trunk" -%}{% assign editor_label = "trunk" -%}{% else -%}{% assign editor_label = "pinnedTrunk" -%}{% endif -%}
34+
code_coverage_project_test_{{ project.name }}_{{ platform.name }}_{{ editor }}:
35+
name: '[Code Coverage] Project Test - NGO {{ project.name }} [{{ platform.name }}, {{ editor }}]'
3236
agent:
3337
type: {{ platform.type }}
3438
image: {{ platform.image }}
@@ -38,13 +42,14 @@ code_coverage_{{ platform.name }}_{{ editor }}:
3842
{% endif %}
3943
commands:
4044
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models
41-
- upm-pvp create-test-project test-project --packages "upm-ci~/packages/*.tgz" --unity .Editor
42-
- UnifiedTestRunner --suite=editor --suite=playmode --editor-location=.Editor --testproject=test-project --enable-code-coverage --coverage-upload-options="reportsDir:$PWD/test-results/CoverageResults;name:NGOv2_{{ platform.name }}_{{ editor }};flags:NGOv2_{{ platform.name }}_{{ editor }};verbose" --coverage-results-path=$PWD/test-results/CoverageResults --coverage-options="generateHtmlReport;generateAdditionalMetrics;assemblyFilters:+Unity.Netcode.Editor,+Unity.Netcode.Runtime" --extra-editor-arg=--burst-disable-compilation --timeout={{ test_timeout }} --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --artifacts-path=test-results
45+
- UnifiedTestRunner --testproject={{ project.path }} --suite=editor --suite=playmode --editor-location=.Editor --enable-code-coverage --coverage-upload-options="reportsDir:$PWD/test-results/CoverageResults;name:NGOv2_project_{{ project.name }}_{{ platform.name }}_{{ editor_label }};flags:NGOv2_project_{{ project.name }}_{{ platform.name }}_{{ editor_label }};verbose" --coverage-results-path=$PWD/test-results/CoverageResults --coverage-options="generateHtmlReport;generateAdditionalMetrics;assemblyFilters:+Unity.Netcode.Editor,+Unity.Netcode.Runtime" --extra-editor-arg=--burst-disable-compilation --timeout={{ test_timeout }} --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --artifacts-path=test-results
4346
artifacts:
4447
logs:
4548
paths:
4649
- "test-results/**/*"
4750
dependencies:
51+
- .yamato/_run-all.yml#run_quick_checks # initial checks to perform fast validation of common errors
4852
- .yamato/package-pack.yml#package_pack_-_ngo_{{ platform.name }}
4953
{% endfor -%}
5054
{% endfor -%}
55+
{% endfor -%}

Tools/CI/service.cmb/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Testing against the CMB Service
22

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.
3+
The CMB Service is a tool that is external to our repository. The tool is inside the `runtime` folder of the [CMB service](https://github.com/Unity-Technologies/unity-player-services/tree/main/services/common-multiplayer-backend) in the Unity Player Services monorepo.
44

55
Due to this, there is some more setup needed when running tests against the CMB Service.
66

@@ -56,3 +56,7 @@ The following environment variables allow for further configuration of the setup
5656
`CMB_SERVICE_PORT` defines the port where the tests will try to connect to the service (defaults to `7789`).
5757

5858
`NGO_HOST` defines the http address where the tests will try to connect to the service (defaults to `127.0.0.1`).
59+
60+
## Running on CI (Yamato)
61+
62+
The CMB tests can also be run from Yamato. The jobs are defined in [`.yamato/cmb-service-standalone-tests.yml`](../../../.yamato/cmb-service-standalone-tests.yml) and appear in Yamato as `CMB Service Test - NGO <project> - [<platform>, <editor>, <backend>]`. The job can be triggered manually from any branch meaning it can be easier to run the CMB tests from Yamato rather than set them up locally. The test uses [`run_cmb_service.sh`](./run_cmb_service.sh) to setup and run the CMB service.

Tools/CI/service.cmb/run_cmb_service.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Example usage:
1818
# ./<path-to-script>/run_cmb_service.sh -e 7788 -s 7799
1919

20-
# This script is currently used in the desktop-standalone-tests yamato job.
20+
# This script is currently used in the cmb-service-standalone-tests yamato job (found at ../../../.yamato/cmb-service-standalone-tests.yml).
2121

2222
# TECHNICAL CONSIDERATIONS---------------------------------------------------------------
2323
# This is a bash script and so needs to be run on a Unix based system.
@@ -136,11 +136,14 @@ else
136136
logMessage "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC"
137137
fi
138138

139-
# clone the cmb service repo
140-
git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git
139+
# Sparse-checkout only the CMB service directory from the unity-player-services monorepo.
140+
# --filter=blob:none + --depth 1 avoids downloading file contents and history for the rest of the monorepo.
141+
git clone --depth 1 --filter=blob:none --sparse https://github.com/Unity-Technologies/unity-player-services.git
142+
cd ./unity-player-services
143+
git sparse-checkout set services/common-multiplayer-backend/runtime
141144

142145
# navigate to the cmb service directory
143-
cd ./mps-common-multiplayer-backend/runtime
146+
cd ./services/common-multiplayer-backend/runtime
144147

145148
# Install rust
146149
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
1414
### Changed
1515

1616

17+
18+
1719
### Deprecated
1820

1921

@@ -22,6 +24,10 @@ Additional documentation and release notes are available at [Multiplayer Documen
2224

2325
### Fixed
2426

27+
- Issue with not being able to spawn initially disabled in-scene placed objects. (#4093)
28+
- Issue with pre-instantiated network prefab instances being marked as in-scene placed. Now pre-instantiated network prefabs are dynamically spawned. (#4093)
29+
- Issue where a user could spawn runtime created `NetworkObject` that has a GlobalObjectIdHash of zero. These are not valid instances and will no longer be allowed to spawn. (#4093)
30+
2531

2632
### Security
2733

com.unity.netcode.gameobjects/Documentation~/advanced-topics/custom-serialization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ Reading and writing a value provides the minimal amount of `NetworkVariable` fun
6868
6969
Here is a full implementation of a custom type with the methods needed for `UserNetworkVariableSerialization`
7070

71-
[!code-cs[](../../Tests/Runtime/DocumentationCodeSamples/NetworkVariable/NetworkVariableSerialization.cs#HealthExample)]
71+
[!code-cs[](../../Tests/Runtime/DocumentationCodeSamples/NetworkVariable/CustomSerializationDocsTests.cs#HealthExample)]

com.unity.netcode.gameobjects/Documentation~/advanced-topics/fastbufferwriter-fastbufferreader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ This allows the four bytes of the embedded struct to be rapidly serialized as a
8282

8383
`FastBufferWriter` and `FastBufferReader` are replacements for the old `NetworkWriter` and `NetworkReader`. For those familiar with the old classes, there are some key differences:
8484

85-
- `FastBufferWriter` uses `WriteValue()` as the name of the method for all types *except* [`INetworkSerializable`](serialization/inetworkserializable) types, which are serialized through `WriteNetworkSerializable()`
85+
- `FastBufferWriter` uses `WriteValue()` as the name of the method for all types *except* [`INetworkSerializable`](serialization/inetworkserializable.md) types, which are serialized through `WriteNetworkSerializable()`
8686
- `FastBufferReader` similarly uses `ReadValue()` for all types except INetworkSerializable (which is read through `ReadNetworkSerializable`), with the output changed from a return value to an `out` parameter to allow for method overload resolution to pick the correct value.
8787
- `FastBufferWriter` and `FastBufferReader` outsource packed writes and reads to `BytePacker` and `ByteUnpacker`, respectively.
8888
- `FastBufferWriter` and `FastBufferReader` are **structs**, not **classes**. This means they can be constructed and destructed without GC allocations.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void AbcdServerRpc(int somenumber) { /* ... */ }
7575
void XyzwServerRpc(int somenumber, ServerRpcParams serverRpcParams = default) { /* ... */ }
7676
```
7777

78-
[ServerRpcParams Documentation](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.ServerRpcParams.html)
78+
[ServerRpcParams Documentation](xref:Unity.Netcode.ServerRpcParams)
7979

8080
## ClientRpc Params
8181

@@ -94,7 +94,7 @@ void AbcdClientRpc(int framekey) { /* ... */ }
9494
void XyzwClientRpc(int framekey, ClientRpcParams clientRpcParams = default) { /* ... */ }
9595
```
9696

97-
[ClientRpcParams Documentation](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.ClientRpcParams.html)
97+
[ClientRpcParams Documentation](xref:Unity.Netcode.ClientRpcParams)
9898

9999
> [!NOTE]
100100
> `ClientRpcSendParams`'s `TargetClientIds` property is a `ulong[]` which means everytime you try to specify a subset of target clients or even a single client target, you will have to allocate a `new ulong[]`. This pattern can quickly lead into lots of heap allocations and pressure GC which would cause GC spikes at runtime. We suggest developers cache their `ulong[]` variables or use an array pool to cycle `ulong[]` instances so that it would cause less heap allocations.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,4 @@ void Update()
328328
## Additional resources
329329

330330
* [RPC parameters](rpc-params.md)
331-
* [Customizing serialization](../custom-serialization.md#remote-procedure-call-rpc)
331+
* [Customizing serialization](../custom-serialization.md#remote-procedure-call-rpcs)

com.unity.netcode.gameobjects/Documentation~/advanced-topics/network-prefab-handler.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The network prefab handler system provides advanced control over how network prefabs are instantiated and destroyed during runtime. You can use it to override the default Netcode for GameObjects [object spawning](../basics/object-spawning.md) behavior by implementing custom prefab handlers.
44

5-
The network prefab handler system is accessible from the [NetworkManager](../components/networkmanager.md) as `NetworkManager.PrefabHandler`.
5+
The network prefab handler system is accessible from the [NetworkManager](../components/core/networkmanager.md) as `NetworkManager.PrefabHandler`.
66

77
## When to use a prefab handler
88

@@ -13,14 +13,14 @@ For an overview of the default object spawning behavior, refer to the [object sp
1313
- **Custom initialization**: Setting up objects with game client specific data or configurations.
1414
- **Conditional spawning**: Initializing different prefab variants based on runtime conditions.
1515

16-
The prefab handler system addresses these needs through an interface-based architecture. The system relies on two key methods: `Instantiate` and `Destroy`. `Instantiate` is called on non-authority clients when an [authority](../terms-concepts/authority.md) spawns a new [NetworkObject](../basics/networkobject.md) that has a registered network prefab handler. `Destroy` is called on all game clients whenever a registered [NetworkObject](../basics/networkobject.md) is destroyed.
16+
The prefab handler system addresses these needs through an interface-based architecture. The system relies on two key methods: `Instantiate` and `Destroy`. `Instantiate` is called on non-authority clients when an [authority](../terms-concepts/authority.md) spawns a new [NetworkObject](../components/core/networkobject.md) that has a registered network prefab handler. `Destroy` is called on all game clients whenever a registered [NetworkObject](../components/core/networkobject.md) is destroyed.
1717

1818
## Create a prefab handler
1919

2020
Prefab handlers are classes that implement one of the Netcode for GameObjects prefab handler descriptions. There are currently two such descriptions:
2121

22-
- [**INetworkPrefabInstanceHandler**](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.INetworkPrefabInstanceHandler.html): This is the simplest interface for custom prefab handlers.
23-
- [**NetworkPrefabInstanceHandlerWithData**](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkPrefabInstanceHandlerWithData.html): This specialized handler receives custom data from the authority during spawning, enabling dynamic prefab customization.
22+
- [**INetworkPrefabInstanceHandler**](xref:Unity.Netcode.INetworkPrefabInstanceHandler): This is the simplest interface for custom prefab handlers.
23+
- [**NetworkPrefabInstanceHandlerWithData**](xref:Unity.Netcode.NetworkPrefabInstanceHandlerWithData): This specialized handler receives custom data from the authority during spawning, enabling dynamic prefab customization.
2424

2525
When using a prefab handler, Netcode for GameObjects uses the `Instantiate` and `Destroy` methods instead of default spawn handlers for the NetworkObject during spawning and despawning. The authority instance uses the traditional spawning approach where it will, via user script, instantiate and spawn a network prefab (even for those registered with a prefab handler). However, all non-authority clients will automatically use the instantiate method defined by the `INetworkPrefabInstanceHandler` implementation if the network prefab spawned has a registered `INetworkPrefabInstanceHandler` implementation with the `NetworkPrefabHandler` (`NetworkManager.PrefabHandler`).
2626

@@ -55,7 +55,7 @@ public abstract class NetworkPrefabInstanceHandlerWithData<T> : INetworkPrefabIn
5555

5656
## Register a prefab handler
5757

58-
Once you've [created a prefab handler](#create-a-prefab-handler), whether by implementing or deriving, you need to register any new instance of that handler with the network prefab handler system using `NetworkManager.PrefabHandler.AddHandler`. Prefab handlers are registered against a NetworkObject's [GlobalObjectIdHash](../basics/networkobject.md#using-networkobjects).
58+
Once you've [created a prefab handler](#create-a-prefab-handler), whether by implementing or deriving, you need to register any new instance of that handler with the network prefab handler system using `NetworkManager.PrefabHandler.AddHandler`. Prefab handlers are registered against a NetworkObject's [GlobalObjectIdHash](../components/core/networkobject.md#using-networkobjects).
5959

6060
```csharp
6161
public class GameManager : NetworkBehaviour
@@ -70,7 +70,7 @@ public class GameManager : NetworkBehaviour
7070
}
7171
```
7272

73-
To un-register a prefab handler, you can [invoke the `NetworkManager.PrefabHandler.RemoveHandler` method](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkPrefabHandler.html#Unity_Netcode_NetworkPrefabHandler_RemoveHandler_System_UInt32_). There are several override versions of this method.
73+
To un-register a prefab handler, you can [invoke the `NetworkManager.PrefabHandler.RemoveHandler` method](xref:Unity.Netcode.NetworkPrefabHandler.RemoveHandler*). There are several override versions of this method.
7474

7575
## Object spawning with prefab handlers
7676

0 commit comments

Comments
 (0)