Skip to content
Joe Osborne edited this page Feb 28, 2020 · 4 revisions

This API reference documents all areas of the public API for Replicator.

Please note: while it is possible to configure a Unity project in a way which allows client code to use them, use of members marked internal is neither intended nor supported for client code.

Contents

Replicator

Namespace containing all of the public Replicator API.

Types

ObjectPool

Asset representing and providing a pool of GameObjects.

Spawn

GameObject Spawn(Vector3 position, Quaternion rotation, Transform parent = null)

Spawn a GameObject from the pool, if one is available.

Parameters

  • position: Position of the spawned GameObject
  • rotation: Rotation of the spawned GameObject
  • parent: (optional) Parent of the spawned GameObject
Recycle

void Recycle(GameObject gameObject)

Recycle the gameObject if it belongs to this pool.

Parameters

  • gameObject : The GameObject to recycle

Interfaces

Interfaces are provided for client code to trigger actions during the Spawn / Recycle lifecycle.

ISpawned

Interface for hooking into a GameObject's spawn phase.

OnSpawn

void OnSpawn()

Callback called after the associated GameObject is spawned, but before it is returned.

IRecycled

Interface for hooking into a GameObject's recycle phase.

OnRecycle

void OnRecycle()

Callback to implement cleanup or other actions when the GameObject this script is attached to is recycled.

IPooled

Implements

Provides callbacks for Spawning & Recycling GameObjects.

Extensions

Monobehaviour

Extensions to UnityEngine.MonoBehaviour to facilitate mimicking Unity's Instantiate and Destroy API.

Spawn

Overloads:

  • GameObject Spawn(GameObject original, Transform parent = null)
  • GameObject Spawn(GameObject original, Vector3 position, Quaternion rotation, Transform parent = null)

Spawn a copy of original if it is a pooled GameObject.

Parameters:

  • original: The GameObject to spawn a copy of
  • position: Position of the spawned GameObject
  • rotation: Rotation of the spawned GameObject
  • parent: (optional) Parent of the spawned GameObject
Recycle

Overloads:

  • void Recycle(GameObject target)
  • void Recycle(GameObject target, float delay)

Recycle the target GameObject, if it was spawned from a pool.

Parameters:

  • target: The GameObject to recycle
  • delay: An optional delay, in seconds, before recycling the GameObject

GameObject

Extensions to UnityEngine.GameObject for Spawning & Recycling them.

Spawn

Overloads:

  • GameObject Spawn(Transform parent = null)
  • GameObject Spawn(Vector3 position, Quaternion rotation, Transform parent = null)

Spawn a copy of the GameObject, if it is a pooled GameObject.

Parameters:

  • position: Position of the spawned GameObject
  • rotation: Rotation of the spawned GameObject
  • parent: (optional) Parent of the spawned GameObject
Recycle

void Recycle()

Recycle this GameObject, if it belongs to a pool.

Clone this wiki locally