Skip to content

Commit 3977cf7

Browse files
committed
Updated pooling documentation
1 parent e836e47 commit 3977cf7

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

docs/_docs/advanced-topics/object-pooling.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,18 @@ permalink: /wiki/object-pooling/
55

66

77
The MLAPI has built-in support for Object Pooling. This is useful for frequently used objects such as bullets.
8+
This can be achieved by registering custom spawn and destroy handlers.
89

9-
_This feature, and it's documentation might be outdated_
1010

11-
12-
### Usage
13-
Here are some examples of how to use the Object Pooling system. Note that all of the calls can only be used on the server.
14-
#### Create a pool
15-
```csharp
16-
//poolName is a string
17-
//spawnablePrefabIndex is the index the object has in your spawnable prefab list
18-
//size is the amount of objects in the pool. More objects require more memory and resources.
19-
NetworkPoolManager.CreatePool(myPoolName, mySpawnablePrefabIndex, mySize);
20-
```
21-
22-
#### Destroy a pool
23-
```csharp
24-
NetworkPoolManager.DestroyPool(myPoolName);
25-
```
26-
#### Spawn object
11+
### SpawnHandler
2712
```csharp
28-
NetworkPoolManager.SpawnPoolObject(myPoolName, myPos, myRot);
13+
SpawnManager.RegisterCustomSpawnHandler(SpawnManager.GetPrefabHash("myPrefabName"), (position, rotation, disabled) {
14+
// Called when the MLAPI want's to spawn a prefab with the name "myPrefabName"
15+
});
2916
```
30-
#### Destroy object
17+
### DestroyHandler
3118
```csharp
32-
NetworkPoolManager.DestroyPoolObject(myNetworkedObject);
19+
SpawnManager.RegisterCustomDestroyHandler(SpawnManager.GetPrefabHash("myPrefabName"), (networkedObject) {
20+
// Called when the MLAPI want's to destroy the given NetworkedObject
21+
});
3322
```

0 commit comments

Comments
 (0)