Runtime Spawner 1.5.1
Generic Runtime spawn and instance pooling system for spawning random AI agents around a map. Works with ANY AI system easily.
Loading...
Searching...
No Matches
MegaCrush.Spawner.PunAdapter.PUNPrefabRegistrar Class Reference

Utility class that automatically registers all prefabs referenced by RuntimeSpawner and its collaborators with a PUNPoolPrefabProvider. More...

Static Public Member Functions

static void RegisterFromSpawner (RuntimeSpawner spawner, PUNPoolPrefabProvider provider, int prewarmEach=0)
 Registers all prefabs referenced by a specific RuntimeSpawner instance (including its global spawners, region spawners, and wave triggers).
 
static void RegisterFromScene (PUNPoolPrefabProvider provider, int prewarmEach=0)
 Scene-wide registration helper. Scans all relevant authoring components in the scene—RuntimeSpawner, LocalAreaSpawner, WaveSpawner, and SpecialEncounterManager—and registers their prefabs with the provided PUNPoolPrefabProvider.
 

Static Private Member Functions

static void TryAdd (GameObject prefab, PUNPoolPrefabProvider provider, HashSet< GameObject > seen, int prewarmEach)
 Attempts to register a prefab with the given provider if it hasn’t already been processed.
 

Detailed Description

Utility class that automatically registers all prefabs referenced by RuntimeSpawner and its collaborators with a PUNPoolPrefabProvider.

This helper ensures that all prefabs used by Runtime Spawner systems are known to Photon Unity Networking (PUN) before gameplay begins, allowing networked spawning to work seamlessly across clients.

It can operate in two modes:

  • RegisterFromSpawner – Registers prefabs directly from a known RuntimeSpawner instance.
  • RegisterFromScene – Performs a full scene sweep, locating all LocalAreaSpawner, WaveSpawner, and SpecialEncounterManager components and registering their referenced prefabs.

Each prefab key is resolved using PUNPoolPrefabProvider.ResolveKey(GameObject), which prefers PUNPrefabKey.Id over the prefab’s name.

Member Function Documentation

◆ RegisterFromScene()

static void MegaCrush.Spawner.PunAdapter.PUNPrefabRegistrar.RegisterFromScene ( PUNPoolPrefabProvider provider,
int prewarmEach = 0 )
static

Scene-wide registration helper. Scans all relevant authoring components in the scene—RuntimeSpawner, LocalAreaSpawner, WaveSpawner, and SpecialEncounterManager—and registers their prefabs with the provided PUNPoolPrefabProvider.

Parameters
providerThe PUNPoolPrefabProvider instance to register prefabs with.
prewarmEachOptional number of instances to prewarm for each prefab.

This method is useful during scene initialization, especially in cooperative or multiplayer setups, where prefabs must be registered with PUN before networked objects are spawned.

◆ RegisterFromSpawner()

static void MegaCrush.Spawner.PunAdapter.PUNPrefabRegistrar.RegisterFromSpawner ( RuntimeSpawner spawner,
PUNPoolPrefabProvider provider,
int prewarmEach = 0 )
static

Registers all prefabs referenced by a specific RuntimeSpawner instance (including its global spawners, region spawners, and wave triggers).

Parameters
spawnerThe RuntimeSpawner to scan for referenced prefabs.
providerThe PUNPoolPrefabProvider to register prefabs with.
prewarmEachNumber of instances to prewarm for each prefab (0 = none).

Use this when you have an explicit reference to the spawner, such as during your multiplayer bootstrap or network session initialization.

◆ TryAdd()

static void MegaCrush.Spawner.PunAdapter.PUNPrefabRegistrar.TryAdd ( GameObject prefab,
PUNPoolPrefabProvider provider,
HashSet< GameObject > seen,
int prewarmEach )
staticprivate

Attempts to register a prefab with the given provider if it hasn’t already been processed.


The documentation for this class was generated from the following file: