Object Pooling
  • Pool Pool Pool
  • Components
    • Pool Manager
    • Pool Asset
    • Project Configuration
  • Interface
  • Global Functions
Powered by GitBook
On this page
  • Overview
  • What it does
  • How to create a pool asset
  • How to Register a pool asset
  • How to use a pool asset
  • Pool Asset Variables
  1. Components

Pool Asset

Class: UObjectPoolClass

PreviousPool ManagerNextProject Configuration

Last updated 10 months ago

Overview

The Pool Asset is a critical component within the Object Pool Manager system. It defines the blueprint for the objects that will be managed within the pool, including their initialization, lifecycle management, and specific configuration settings. This allows developers to streamline object management, improve performance, and ensure that objects are efficiently recycled and reused.

What it does

The Pool Asset encapsulates all necessary information for creating and managing a pool of reusable objects. It specifies which objects are included in the pool, how they are initialized, and the conditions under which they are recycled or expanded. By defining these parameters, the Pool Asset ensures that the Object Pool Manager can handle objects dynamically and efficiently, without unnecessary overhead.

How to create a pool asset

To create a Pool Asset, follow these steps:

  1. Create a New Class: Create a new class that inherits from UObjectPoolClass. This class will serve as the Pool Asset.

  2. Define Pool Configuration: In the new class, define the object pool objects using the provided variables.

How to Register a pool asset

You need to register this asset with a key for global use.

Project Configuration

Register assets before using them

How to use a pool asset

Once the Pool Asset is created, it can be used within the Object Pool Manager to manage object pools efficiently. Here’s how to use it:

  1. Add Pool Asset to Object Pool Manager: Register the Pool Asset within the Project Configuration

  2. Initialize Pool Asset: The Object Pool Manager will automatically initialize the Pool Asset based on the defined configuration when the game starts or when the pool is explicitly initialized.

  3. Request and Return Objects: Use the Object Pool Manager’s API to request and return objects from the pool as needed.

  4. Monitor and Debug: Utilize the debugging and monitoring features to ensure the pool operates efficiently and to troubleshoot any issues.

Pool Asset Variables

The following are the key variables used in a Pool Asset and their purposes:

  • ObjectPool: A map that stores the pool data for each registered object. Each entry includes initialization parameters, object references, and lifecycle management settings.

  • bEnable: A boolean flag indicating whether the object pool is enabled and should be managed by the pool manager.

  • bRecycleInactiveObjects: Indicates whether inactive objects should be recycled periodically.

  • RecyclePerCycle: The number of objects to recycle during each cycle.

  • RecycleThreshold: The threshold below which objects will not be recycled.

  • bAutoExpandPool: Determines if the pool should automatically expand when needed.

  • AutoScaleThreshold: The threshold for triggering automatic pool expansion.

  • AutoScaleAmount: The number of objects to add to the pool when it auto-expands.

  • InstantSpawn: The number of objects to spawn instantly when the pool is initialized.

  • DebugPool: Enables debug information for the pool, allowing developers to see detailed information about the pool’s state.