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/Documentation~/basics/scenemanagement/custom-management.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Once you've registered your in-scene placed Network Prefabs with your `NetworkPr
39
39
> When a client first connects, it deletes any in-scene placed `NetworkObjects` in any of the scenes it has currently loaded. When using a custom scene management solution, in-scene placed NetworkObjects are actually dynamically spawned. This means any changes you make to your in-scene placed Network Prefabs will *not* be synchronized with clients automatically.
If you want to change an in-scene placed network prefab instance, you need to handle the serialization of these settings yourself. You can do this by overriding `NetworkBehaviour.OnSynchronize` and serializing any property updates you want to have synchronized with clients when they join. [Read More About OnSynchronize Here](../../components/core/networkbehaviour.md#pre-spawn-synchronization).
42
+
If you want to change an in-scene placed network prefab instance, you need to handle the serialization of these settings yourself. You can do this by overriding `NetworkBehaviour.OnSynchronize` and serializing any property updates you want to have synchronized with clients when they join. [Read More About OnSynchronize Here](../../components/core/networkbehaviour.md#prespawn-synchronization).
43
43
44
44
## Starting a Netcode Enabled Game Session
45
45
The recommended way of starting session using your own scene management solution is to assure that when a client attempts to join a netcode game session it should already have (as best as possible) any scenes that the server might have loaded. While this does not assure that your newly connecting client will load any additional scenes that might have been loaded, using this approach initially will get you started so you can then come up with a strategy to handling:
|**[NetworkBehaviour](networkbehaviour.md)**|[NetworkBehaviour](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkBehaviour.html) is an abstract class that derives from [MonoBehaviour](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) must have a [NetworkObject](networkobject.md) component and at least one NetworkBehaviour component. |
24
-
|**[Synchronizing](networkbehaviour-synchronize.md)**| Understand a NetworkBehaviour component's order of operations when it comes to spawning, de-spawning, and adding custom synchronization data. |
24
+
|**[Synchronizing](networkbehaviour-synchronize.md)**| Understand a NetworkBehaviour component's order of operations when it comes to spawning, despawning, and adding custom synchronization data. |
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/components/core/networkbehaviour-synchronize.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,24 @@ You can use NetworkBehaviours to synchronize settings before, during, and after
6
6
7
7
For more information about spawning and despawning NetworkBehaviours, refer to the [NetworkBehaviour spawning and despawning page](networkbehaviour.md).
8
8
9
-
## Pre-spawn, spawn, post-spawn and synchronization
9
+
## Prespawn, spawn, post-spawn and synchronization
10
10
11
11
The NetworkObject spawn process can become complicated when there are multiple NetworkBehaviour components attached to the same GameObject. Additionally, there can be times where you want to be able to handle pre- and post-spawn oriented tasks.
12
12
13
-
-Pre-spawn example: Instantiating a `NetworkVariable` with owner write permissions and assigning a value to that `NetworkVariable` on the server or host side.
13
+
-Prespawn example: Instantiating a `NetworkVariable` with owner write permissions and assigning a value to that `NetworkVariable` on the server or host side.
14
14
- Spawn example: Applying a local value or setting that may be used during post spawn by another local NetworkBehaviour component.
15
15
- Post-spawn example: Accessing a `NetworkVariable` or other property that is set during the spawn process.
16
16
17
17
Below are the three virtual methods you can override within a NetworkBehaviour-derived class:
OnNetworkPreSpawn | NetworkObject | Pre-spawn initialization | Client and server
21
+
OnNetworkPreSpawn | NetworkObject | Prespawn initialization | Client and server
22
22
OnNetworkSpawn | NetworkObject | During spawn initialization | Client and server
23
23
OnNetworkPostSpawn | NetworkObject | Post-spawn actions | Client and server
24
24
OnNetworkSessionSynchronized | All NetworkObjects | New client finished synchronizing | Client-side only
25
25
OnInSceneObjectsSpawned | In-scene NetworkObjects | New client finished synchronizing or a scene is loaded | Client and server
26
-
OnNetworkPreDespawn | NetworkObject | Invoked before de-spawning NetworkObject | Client and server
26
+
OnNetworkPreDespawn | NetworkObject | Invoked before despawning NetworkObject | Client and server
27
27
28
28
In addition to the methods above, there are two special case convenience methods:
29
29
@@ -33,7 +33,7 @@ In addition to the methods above, there are two special case convenience methods
33
33
- A client finishes synchronizing.
34
34
- On the server and client side after a scene has been loaded and all newly instantiated in-scene placed NetworkObjects have been spawned.
35
35
36
-
### Pre-spawn synchronization with `OnSynchronize`
36
+
### Prespawn synchronization with `OnSynchronize`
37
37
38
38
There can be scenarios where you need to include additional configuration data or use a NetworkBehaviour to configure some non-netcode related component (or the like) before a NetworkObject is spawned. This can be particularly critical if you want specific settings applied before `NetworkBehaviour.OnNetworkSpawn` is invoked. When a client is synchronizing with an existing network session, this can become problematic as messaging requires a client to be fully synchronized before you know "it is safe" to send the message, and even if you send a message there is the latency involved in the whole process that might not be convenient and can require additional specialized code to account for this.
0 commit comments