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
# 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
# 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
19
20
# Requires Unity Editor installation
20
21
# Burst compilation is disabled to ensure accurate coverage measurement
21
22
# 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
Copy file name to clipboardExpand all lines: Tools/CI/service.cmb/README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Testing against the CMB Service
2
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.
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.
4
4
5
5
Due to this, there is some more setup needed when running tests against the CMB Service.
6
6
@@ -56,3 +56,7 @@ The following environment variables allow for further configuration of the setup
56
56
`CMB_SERVICE_PORT` defines the port where the tests will try to connect to the service (defaults to `7789`).
57
57
58
58
`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.
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
14
14
### Changed
15
15
16
16
17
+
18
+
17
19
### Deprecated
18
20
19
21
@@ -22,6 +24,10 @@ Additional documentation and release notes are available at [Multiplayer Documen
22
24
23
25
### Fixed
24
26
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)
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/basics/scenemanagement/inscene-placed-networkobjects.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,9 +184,13 @@ public class MyInSceneNetworkObjectBehaviour : NetworkBehaviour
184
184
> [!NOTE]
185
185
> You only need to enable the NetworkObject on the server-side to be able to respawn it. Netcode for GameObjects only enables a disabled in-scene placed NetworkObject on the client-side if the server-side spawns it. This **does not** apply to dynamically spawned `NetworkObjects`. Refer to [the object pooling page](../../advanced-topics/object-pooling.md) for an example of recycling dynamically spawned NetworkObjects.
186
186
187
+
### Pre-disabled in-scene placed NetworkObjects
188
+
189
+
To initialize an in-scene placed NetworkObject in a disabled state and spawn it later, set its GameObject to inactive in the Editor while the respective scene is open. Once a networked session begins, you can re-enable and spawn it at any time.
190
+
187
191
### Setting an in-scene placed NetworkObject to a despawned state when instantiating
188
192
189
-
Since in-scene placed NetworkObjects are automatically spawned when their respective scene has finished loading during a network session, you might run into the scenario where you want it to start in a despawned state until a certain condition has been met. To do this, you need to add some additional code in the `OnNetworkSpawn` part of your NetworkBehaviour component:
193
+
To programmatically disable an in-scene placed NetworkObject, add some additional code in the `OnNetworkSpawn` part of a NetworkBehaviour component:
The following provides the validity requirements for both types.
29
+
30
+
#### Dynamically instantiated network prefabs
31
+
32
+
Dynamically instantiated network prefabs must:
33
+
34
+
* Be a valid [network prefab](./networkobject.md#network-prefabs) created within the Editor.
35
+
* Be registered in a network prefab list that's assigned to your NetworkManager.
36
+
37
+
#### In-scene placed network prefabs
38
+
39
+
In-scene placed network prefabs must:
40
+
41
+
* Be a valid network prefab instance within a scene.
42
+
* Be a GameObject with a NetworkObject component created within the scene while in the Editor.
43
+
44
+
### What is an invalid NetworkObject?
45
+
46
+
GameObjects that have NetworkObject components added to them during runtime are **not supported** and will result in the NetworkObject's `GlobalObjectIdHash` being zero, which causes synchronization issues. In the event you make this mistake, a warning message will be logged and the NetworkObject won't be spawned.
47
+
22
48
### Component order
23
49
24
50
The order of components on a networked GameObject matters. When adding netcode components to a GameObject, ensure that the NetworkObject component is ordered before any NetworkBehaviour components.
// Trap for users just creating things during runtime where this will be zero.
28
+
if(networkObject.GlobalObjectIdHash==0)
29
+
{
30
+
log.Warning(newContext(LogLevel.Developer,$"{nameof(NetworkObject)}'s GlobalObjectIdHash value is zero! Runtime creating of {nameof(NetworkObject)}s is not supported. Skipping processing.").AddNetworkObject(networkObject));
log.Warning(newContext(LogLevel.Developer,$"{nameof(NetworkObject)}'s SceneOrigin doesn't match current scene being processed! Skipping processing.").AddInfo("SceneOrigin",networkObject.SceneOriginHandle).AddNetworkObject(networkObject));
@@ -36,7 +42,15 @@ public void OnProcessScene(Scene scene, BuildReport report)
36
42
continue;
37
43
}
38
44
45
+
// If already marked, the do nothing.
46
+
if(networkObject.InScenePlaced)
47
+
{
48
+
continue;
49
+
}
50
+
39
51
networkObject.InScenePlaced=true;
52
+
// Will not be true when making a build and the values are serialized.
Debug.LogError($"{nameof(NetworkAnimator)}{name} does not have an {nameof(UnityEngine.Animator)} assigned to it. The {nameof(NetworkAnimator)} will not initialize properly.");
771
+
Debug.LogWarning($"{nameof(NetworkAnimator)}{name} does not have an {nameof(UnityEngine.Animator)} assigned to it. The {nameof(NetworkAnimator)} will not initialize properly.");
0 commit comments