Base type used to load resources of type TResource using info of type TInfo.
TInfo is used as key if the same resource is requested on multiple Entity to only load the TResource resource once.
If no Entity contains the ManagedResource<TInfo,TResource> component identifying the resource anymore, the TResource instance is then unloaded automatically.
By default, if TResource is System.IDisposable, Unload(TInfo, TResource) will call the System.IDisposable.Dispose method of the resource.
public abstract class AResourceManager<TInfo,TResource> :
System.IDisposable
TInfo
The type used to identify a resource.
TResource
The type of the resource.
Inheritance System.Object 🡒 AResourceManager<TInfo,TResource>
Implements System.IDisposable
Constructors | |
---|---|
AResourceManager() | Creates an instance of type AResourceManager<TInfo,TResource>. |
Properties | |
---|---|
Resources | Gets all the TResource loaded by the current instance and their corresponding TInfo. |
Methods | |
---|---|
Dispose() | Unloads all loaded resources. |
Load(TInfo) | Loads a resource of type TResource using the provided TInfo parameter. |
Manage(World) | Sets up current AResourceManager<TInfo,TResource> instance to react to ManagedResource<TInfo,TResource> components on Entity instances of the provided World. Once no Entity contains a ManagedResource<TInfo,TResource> component anymore, the shared TResource resource is disposed automatically. |
OnResourceLoaded(Entity, TInfo, TResource) | Called when a resource is loaded from a ManagedResource<TInfo,TResource> component of an Entity. |
Unload(TInfo, TResource) | Unloads a resource once it is no longer referenced by a ManagedResource<TInfo,TResource>. By default if TResource is System.IDisposable, calls the System.IDisposable.Dispose method. |