Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (20 sloc) 705 Bytes
title permalink
Object Pooling

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


SpawnManager.RegisterCustomSpawnHandler(SpawnManager.GetPrefabHash("myPrefabName"), (position, rotation, disabled) =>
    // Called when the MLAPI want's to spawn a prefab with the name "myPrefabName"


SpawnManager.RegisterCustomDestroyHandler(SpawnManager.GetPrefabHash("myPrefabName"), (networkedObject) =>
    // Called when the MLAPI want's to destroy the given NetworkedObject
You can’t perform that action at this time.