Infohazard.Core.Addressables 1.0.0
Infohazard Core Addressables Integration
Loading...
Searching...
No Matches
Infohazard.Core.Addressables.AddressablePoolHandler Class Reference

An IPoolHandler that loads an addressable from a key. More...

Public Member Functions

 AddressablePoolHandler (object key, Transform transform)
 Construct AddressablePoolHandler given addressable key and parent transform. More...
 
override string ToString ()
 
override Spawnable Spawn ()
 
override void Despawn (Spawnable instance)
 
UniTask RetainAndWaitAsync ()
 Add a user to the AddressablePoolHandler. If not already loaded, the prefab will be loaded asynchronously. More...
 
async UniTask WaitUntilLoadedAsync ()
 If the prefab is currently loading, wait until it is done asynchronously. More...
 
void RetainAndWait ()
 Add a user to the AddressablePoolHandler. If not already loaded, the prefab will be loaded and block. More...
 
void WaitUntilLoaded ()
 If the prefab is currently loading, wait until it is done synchronously. More...
 
override void Retain ()
 Add a user to the AddressablePoolHandler. More...
 

Protected Member Functions

override Spawnable Instantiate ()
 
override void Destroy (Spawnable obj)
 
override bool ShouldClear ()
 
override void Clear ()
 Destroy all pooled instances and unload the addressable if it is loaded. More...
 

Properties

object Key [get]
 Key of the addressable to spawn (path or GUID). More...
 
LoadState State [get, private set]
 State of loading the given addressable. More...
 
int ReferenceCount [get, private set]
 Number of active objects spawned from this AddressablePoolHandler. More...
 
AsyncOperationHandle< GameObject > LoadOperation [get, private set]
 Loading operation for the addressable if it is loading or loaded. More...
 

Detailed Description

An IPoolHandler that loads an addressable from a key.

Constructor & Destructor Documentation

◆ AddressablePoolHandler()

Infohazard.Core.Addressables.AddressablePoolHandler.AddressablePoolHandler ( object  key,
Transform  transform 
)

Construct AddressablePoolHandler given addressable key and parent transform.

Parameters
keyKey of the addressable to spawn (path or GUID).
transformTransform to parent inactive pooled objects to.

Member Function Documentation

◆ Clear()

override void Infohazard.Core.Addressables.AddressablePoolHandler.Clear ( )
protected

Destroy all pooled instances and unload the addressable if it is loaded.

◆ Despawn()

override void Infohazard.Core.Addressables.AddressablePoolHandler.Despawn ( Spawnable  instance)

◆ Destroy()

override void Infohazard.Core.Addressables.AddressablePoolHandler.Destroy ( Spawnable  obj)
protected

◆ Instantiate()

override Spawnable Infohazard.Core.Addressables.AddressablePoolHandler.Instantiate ( )
protected

◆ Retain()

override void Infohazard.Core.Addressables.AddressablePoolHandler.Retain ( )

Add a user to the AddressablePoolHandler.

Does not wait for the loading to finish.

◆ RetainAndWait()

void Infohazard.Core.Addressables.AddressablePoolHandler.RetainAndWait ( )

Add a user to the AddressablePoolHandler. If not already loaded, the prefab will be loaded and block.

◆ RetainAndWaitAsync()

UniTask Infohazard.Core.Addressables.AddressablePoolHandler.RetainAndWaitAsync ( )

Add a user to the AddressablePoolHandler. If not already loaded, the prefab will be loaded asynchronously.

If the prefab is already loaded, this will return synchronously.

◆ ShouldClear()

override bool Infohazard.Core.Addressables.AddressablePoolHandler.ShouldClear ( )
protected

Unlike a DefaultPoolHandler, an AddressablePoolHandler should only clear if both the DefaultPoolHandler.RetainCount (users) and ReferenceCount (spawned objects) are zero. This is because unloading the addressable will also unload any assets needed by the spawned instances, causing missing materials/meshes/textures, etc.

Returns
Whether the pooled instances should be cleared and the addressable unloaded.

◆ Spawn()

override Spawnable Infohazard.Core.Addressables.AddressablePoolHandler.Spawn ( )

◆ ToString()

override string Infohazard.Core.Addressables.AddressablePoolHandler.ToString ( )

◆ WaitUntilLoaded()

void Infohazard.Core.Addressables.AddressablePoolHandler.WaitUntilLoaded ( )

If the prefab is currently loading, wait until it is done synchronously.

This will not start loading the prefab if it is not already loading.

◆ WaitUntilLoadedAsync()

async UniTask Infohazard.Core.Addressables.AddressablePoolHandler.WaitUntilLoadedAsync ( )

If the prefab is currently loading, wait until it is done asynchronously.

This will not start loading the prefab if it is not already loading.

Property Documentation

◆ Key

object Infohazard.Core.Addressables.AddressablePoolHandler.Key
get

Key of the addressable to spawn (path or GUID).

◆ LoadOperation

AsyncOperationHandle<GameObject> Infohazard.Core.Addressables.AddressablePoolHandler.LoadOperation
getprivate set

Loading operation for the addressable if it is loading or loaded.

◆ ReferenceCount

int Infohazard.Core.Addressables.AddressablePoolHandler.ReferenceCount
getprivate set

Number of active objects spawned from this AddressablePoolHandler.

The addressable can be unloaded if ReferenceCount AND DefaultPoolHandler.RetainCount both reach zero.

◆ State

LoadState Infohazard.Core.Addressables.AddressablePoolHandler.State
getprivate set

State of loading the given addressable.


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