Photon Fusion 1.1.11

Public Member Functions | List of all members
INetworkObjectPool Interface Reference

Interface which defines the handlers for NetworkRunner Spawn() and Despawn() actions. Passing an instance of this interface to NetworkRunner.StartGame(StartGameArgs) as the StartGameArgs.ObjectPool argument value will assign that instance as the handler for runner Spawn() and Despawn() actions. By default (if StartGameArgs.ObjectPool == null) actions will use Instantiate(), and Despawn() actions will use Destroy(). More...

Inherited by NetworkObjectPoolDefault.

Public Member Functions

NetworkObject AcquireInstance (NetworkRunner runner, NetworkPrefabInfo info)
 The pooling implementation used for Spawn() actions. More...
 
void ReleaseInstance (NetworkRunner runner, NetworkObject instance, bool isSceneObject)
 The pooling handler implementation for Despawn() actions. More...
 

Detailed Description

Interface which defines the handlers for NetworkRunner Spawn() and Despawn() actions. Passing an instance of this interface to NetworkRunner.StartGame(StartGameArgs) as the StartGameArgs.ObjectPool argument value will assign that instance as the handler for runner Spawn() and Despawn() actions. By default (if StartGameArgs.ObjectPool == null) actions will use Instantiate(), and Despawn() actions will use Destroy().

Member Function Documentation

◆ AcquireInstance()

NetworkObject AcquireInstance ( NetworkRunner  runner,
NetworkPrefabInfo  info 
)

The pooling implementation used for Spawn() actions.

Parameters
runnerThe NetworkRunner which Spawn() is being called from.
infoMeta data about the prefab being spawned. Typical usage:
| NetworkObject AcquireInstance(NetworkRunner runner, NetworkPrefabInfo info)
| {
| if(runner.Config.PrefabTable.TryGetPrefab(info.Prefab, out NetworkObject prefab)){
| // Instantiate or Get Prefab prefab from your custom pool.
| }
| }
NetworkObject AcquireInstance(NetworkRunner runner, NetworkPrefabInfo info)
The pooling implementation used for Spawn() actions.
Returns

◆ ReleaseInstance()

void ReleaseInstance ( NetworkRunner  runner,
NetworkObject  instance,
bool  isSceneObject 
)

The pooling handler implementation for Despawn() actions.

Parameters
runnerThe NetworkRunner which Despawn() is being called from.
instanceThe NetworkObject being released. Disable or Destroy this object as needed.
isSceneObjectIndicates if this GameObject was created by a Spawn action, or if it originated as an object in a loaded scene. Scene objects may need special handling, such as being returned to the scene disabled, rather than being returned to the general pool.