An ObjectPool For Unreal Engine 5
More detail in this Doc
Drag the BP_LoadObjectPool actor into the level, it will automatically register the object pool defined by DA_LevelObjectPool_FistPersonMap.Then you can use SpawnActor or GetUObject in ObjectPoolSubsystem.
This class is used to define a pool class, the class in this DataAsset must implement the interface IPoolInterface.
This is a array of PoolClassDataAsset, it is used to define a pool in a level, you can register multiple pools in a level by spawn and destroy LevelLoadObjectPoolActor.
This is a base interface for the class that you want to use in the object pool, if you want any object to be pooled, you must implement this interface.
This is a subclass of IPoolInterface, it is used to define the actor's behavior when it is spawned or despawned.
You can define your own interface by inheriting from IPoolInterface, such as IPoolPawnInterface, IPoolCharacterInterface. But notice that you must really know the lifetime and behavior of the object you want to pool, you can see details in the IPoolActorInterface, see what is done in function ReleaseToPool, AttachToLevel, OnObjectNew, and you must do the same thing in your own interface.
This actor is a normal actor spawned by UWorld::SpawnActor, used to register and unregister the object pool defined by LevelObjectPoolDataAsset when this actor BeginPlay and EndPlay. You can control the lifetime of the object pool by spawn and destroy this actor.
This Actor can be spawned by UObjectPoolSubsystem::SpawnActor, do not call this actor's Destroy function, use ReleaseToPool instead, if you called Destroy, will crash in IPoolActorInterface::AbortActorDestroy.