Skip to content

Commit 95bc5f8

Browse files
authored
Merge pull request #190 from simon-winter/patch-1
docs(object-spawning): added more Info about .Spawn() method
2 parents 906568d + a4e68f7 commit 95bc5f8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/_docs/the-basics/object-spawning.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ GameObject go = Instantiate(myPrefab, Vector3.zero, Quaternion.identity);
1212
go.GetComponent<NetworkedObject>().Spawn();
1313
```
1414

15+
The .Spawn() method takes 2 parameters, both with default values, so they are optional.
16+
```csharp
17+
public void Spawn(Stream spawnPayload = null, bool destroyWithScene = false);
18+
```
19+
The first parameter is a System.IO.Stream and can be retrieved in the NetworkStart() to sync values once when spawning this object. Note however, that the payload data is only avalible for people that get the spawn call straight away. People that join later on won't get the payload data.
20+
21+
The second parameter speaks for itself. If set to true, the object will be destroyed on scene switching. This can only be set inside the spawn call.
22+
1523
## Scene Objects
1624
Any objects already on the server with NetworkedObject components (static scene objects) will get automatically replicated.
1725

@@ -21,4 +29,4 @@ There are **two** modes that define how scene objects are spawned. The first mod
2129
If PrefabSync is disabled, the MLAPI will use SoftSync. This allows scene objects to be non prefabs and they will not be replaced, thus keeping their serialized data. **This mode is recommended for single project setups**. This is the default since MLAPI 6.
2230

2331
#### PrefabSync
24-
If it's enabled, every scene object has to be a prefab and scene objects are recreated on the client side. This means that serialized data gets lost on the clients. It's thus recommended to place serialized data in NetworkedVars. **This mode is ONLY recommended for Multi project setups**. This was the default before MLAPI 6.
32+
If it's enabled, every scene object has to be a prefab and scene objects are recreated on the client side. This means that serialized data gets lost on the clients. It's thus recommended to place serialized data in NetworkedVars. **This mode is ONLY recommended for Multi project setups**. This was the default before MLAPI 6.

0 commit comments

Comments
 (0)