Prefab Pools

Prefab Pools is an optional feature. Whenever you want to spawn a single specific prefab you do not need to use Prefab Pools. Using Prefab Pools allows your Spawners to use a weighted list of prefabs instead of a single "hard-coded" prefab. Meaning, not only can you add multiple different prefabs into the Prefab Pool, but you can give each prefab a weight, so that you can specify that you want prefab A to appear 3 times as often as prefab B. A single prefab can appear in different Prefab Pools and have different weights in each. A single Prefab Pool can be used by any number of Spawners. Spawners that use Prefab Pools for a wave will choose a random prefab from the weighted pool for each spawn. Despite the similarity in naming, a Prefab Pool however has *nothing to do* with object pooling - the type that gets around Instantiate and Destroy calls by enabling and disabling objects. Our included version of object pooling is called Pool Boss.

The Prefab Pools are located under the sub-Game Object of LevelWaveSettings called "PrefabPools". A simple Prefab Pool looks like this:

 

 

The following fields appear in the Inspector for a Prefab Pool:

     
  1. Spawn Sequence: You can choose from either Randomized (the default) or Original Pool Order. The latter will spawn from the pool exactly as you have set the items in the pool. Example: 1 of item 1, then 3 of item 2, then 1 of item 3, then repeat.
  2.  
  3. Exhaust Before Repeat: This field only appears in random Spawn Sequence. This checkbox is on by default and means that the pool items must all be used before it can refill the pool. In other words, if your pool has prefab A with a weight of 2 and prefab B with a weight of 1, and your Spawner spawns 2 of prefab A in a row, then the next item spawned MUST be prefab B, since that is the only item left in the pool (and then the pool will refill and start over). If Exhaust Before Repeat is unchecked, each random spawned item is just "another flip of the coin" and the pool is never depleted or refiled.
  4.  
  5. Listener: Here you can drag in a WavePrefabPoolListener to hook into key events and do customized coding. Read more about Listeners.
  6.  
  7. Scene Objects Using: These buttons for "List" and "Select" allow you to see which Spawners & Killables use the current Prefab Pool. This is useful so you know what you’ll be affecting before you make changes or delete the pool.
  8.  
  9. Yello Drag Area: Drag a prefab into this area to create a new item in the Prefab Pool.
  10.  
  11. Prefab Pool Items Section: The following controls are here:
       
    • Title Bar Controls: Buttons and Icons that do the following:
         
      • Alpha Sort: Sort the items by prefab name.
      •  
      • Collapse / Expand Buttons: Collapse or expand all Pool items.
      •  
      • Add Button: Adds a new blank Prefab Pool item to the end.
    •  
    • Each Prefab Pool item has the following settings:
         
      • Title Bar Controls: Buttons and Icons that do the following:
           
        • Shift Up / Down Icon: Use these icons to re-order your items, for your preference only.
        •  
        • Clone Icon: Creates a copy of the Item just after Item.
        •  
        • Delete Button: Deletes the Item.
      •  
      • Active Mode: This controls whether when the item is included in the Prefab Pool. There are four settings:
           
        • Always: The default. It's in the pool.
        •  
        • Never: It's never in the pool.
           
        • If World Variable In Range: This lets you define a range for a World Variable value that must be satisfied for the Item to be in the pool. For example, the Item will be in the pool if your experience points is between 1000 and 2000.
           
        • If World Variable Outside Range: Opposite of "In Range". This will let you not have to worry about upper limits. For example you could say an Item is in the pool if outside the range of 0-1000 XP. So it will start to show up after you reach 1000 no matter how many experience points you get.

        Note: The "Range" options are rechecked for current World Variable values every time the Prefab Pool refills when it has been emptied.
      •  
      • Prefab: The prefab for the item. Drag a prefab into this field to change what will be spawned for this item.
      •  
      • Weight: The relative weight of this item compared to other items in this pool. The sum of all weights in this pool is the pool size (for depletion and randomness purposes).

        Note: During runtime, if you select the Prefab Pool in the Hierarchy, the Inspector will show the number of each item remaining in the pool at all times.