Class ResourceManager
Entry point for ResourceManager API
Inheritance
Namespace: UnityEngine.ResourceManagement
Syntax
public class ResourceManager : IDisposable
Constructors
ResourceManager(IAllocationStrategy)
Constructor for the resource manager.
Declaration
public ResourceManager(IAllocationStrategy alloc = null)
Parameters
Type | Name | Description |
---|---|---|
IAllocationStrategy | alloc | The allocation strategy to use. |
Properties
Allocator
The allocation strategy object.
Declaration
public IAllocationStrategy Allocator { get; set; }
Property Value
Type | Description |
---|---|
IAllocationStrategy |
CertificateHandlerInstance
The CertificateHandler instance object.
Declaration
public CertificateHandler CertificateHandlerInstance { get; set; }
Property Value
Type | Description |
---|---|
CertificateHandler |
ExceptionHandler
Global exception handler. This will be called whenever an IAsyncOperation.OperationException is set to a non-null value.
Declaration
public static Action<AsyncOperationHandle, Exception> ExceptionHandler { get; set; }
Property Value
Type | Description |
---|---|
System.Action<AsyncOperationHandle, System.Exception> |
ResourceProviders
Gets the list of configured IResourceProvider objects. Resource Providers handle load and release operations for IResourceLocation objects.
Declaration
public IList<IResourceProvider> ResourceProviders { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<IResourceProvider> | The resource providers list. |
Methods
Acquire(AsyncOperationHandle)
Increment reference count of operation handle.
Declaration
public void Acquire(AsyncOperationHandle handle)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationHandle | handle | The handle to the resource to increment the reference count for. |
AddUpdateReceiver(IUpdateReceiver)
Add an update reveiver.
Declaration
public void AddUpdateReceiver(IUpdateReceiver receiver)
Parameters
Type | Name | Description |
---|---|---|
IUpdateReceiver | receiver | The object to add. The Update method will be called until the object is removed. |
CleanupSceneInstances(Scene)
Declaration
public void CleanupSceneInstances(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene |
ClearDiagnosticCallbacks()
Clears out the diagnostics callbacks handler.
Declaration
public void ClearDiagnosticCallbacks()
ClearDiagnosticsCallback()
Clears out the diagnostics callback handler.
Declaration
[Obsolete("ClearDiagnosticsCallback is Obsolete, use ClearDiagnosticCallbacks instead.")]
public void ClearDiagnosticsCallback()
CreateChainOperation<TObject>(AsyncOperationHandle, Func<AsyncOperationHandle, AsyncOperationHandle<TObject>>)
Create a chain operation to handle dependencies.
Declaration
public AsyncOperationHandle<TObject> CreateChainOperation<TObject>(AsyncOperationHandle dependentOp, Func<AsyncOperationHandle, AsyncOperationHandle<TObject>> callback)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationHandle | dependentOp | The dependency operation. |
System.Func<AsyncOperationHandle, AsyncOperationHandle<TObject>> | callback | The callback method that will create the dependent operation from the dependency operation. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<TObject> | The operation handle. |
Type Parameters
Name | Description |
---|---|
TObject | The type of operation handle to return. |
CreateChainOperation<TObject, TObjectDependency>(AsyncOperationHandle<TObjectDependency>, Func<AsyncOperationHandle<TObjectDependency>, AsyncOperationHandle<TObject>>)
Create a chain operation to handle dependencies.
Declaration
public AsyncOperationHandle<TObject> CreateChainOperation<TObject, TObjectDependency>(AsyncOperationHandle<TObjectDependency> dependentOp, Func<AsyncOperationHandle<TObjectDependency>, AsyncOperationHandle<TObject>> callback)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationHandle<TObjectDependency> | dependentOp | The dependency operation. |
System.Func<AsyncOperationHandle<TObjectDependency>, AsyncOperationHandle<TObject>> | callback | The callback method that will create the dependent operation from the dependency operation. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<TObject> | The operation handle. |
Type Parameters
Name | Description |
---|---|
TObject | The type of operation handle to return. |
TObjectDependency | The type of the dependency operation. |
CreateCompletedOperation<TObject>(TObject, String)
Creates an operation that has already completed with a specified result and error message./>.
Declaration
public AsyncOperationHandle<TObject> CreateCompletedOperation<TObject>(TObject result, string errorMsg)
Parameters
Type | Name | Description |
---|---|---|
TObject | result | The result that the operation will provide. |
System.String | errorMsg | The error message if the operation should be in the failed state. Otherwise null or empty string. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<TObject> |
Type Parameters
Name | Description |
---|---|
TObject | Object type. |
Dispose()
Disposes internal resources used by the resource manager
Declaration
public void Dispose()
GetResourceProvider(Type, IResourceLocation)
Gets the appropriate IResourceProvider for the given location
and type
.
Declaration
public IResourceProvider GetResourceProvider(Type t, IResourceLocation location)
Parameters
Type | Name | Description |
---|---|---|
System.Type | t | |
IResourceLocation | location | The resource location. |
Returns
Type | Description |
---|---|
IResourceProvider | The resource provider. Or null if an appropriate provider cannot be found |
ProvideInstance(IInstanceProvider, IResourceLocation, InstantiationParameters)
Asynchronouslly instantiate a prefab (GameObject) at the specified location
.
Declaration
public AsyncOperationHandle<GameObject> ProvideInstance(IInstanceProvider provider, IResourceLocation location, InstantiationParameters instantiateParameters)
Parameters
Type | Name | Description |
---|---|---|
IInstanceProvider | provider | An implementation of IInstanceProvider that will be used to instantiate and destroy the GameObject. |
IResourceLocation | location | Location of the prefab. |
InstantiationParameters | instantiateParameters | A struct containing the parameters to pass the the Instantiation call. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<GameObject> | Async operation that will complete when the prefab is instantiated. |
ProvideResource<TObject>(IResourceLocation)
Load the TObject
at the specified location
.
Declaration
public AsyncOperationHandle<TObject> ProvideResource<TObject>(IResourceLocation location)
Parameters
Type | Name | Description |
---|---|---|
IResourceLocation | location | Location to load. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<TObject> | An async operation. |
Type Parameters
Name | Description |
---|---|
TObject | Object type to load. |
ProvideResources<TObject>(IList<IResourceLocation>, Action<TObject>)
Asynchronously load all objects in the given collection of locations
.
Declaration
public AsyncOperationHandle<IList<TObject>> ProvideResources<TObject>(IList<IResourceLocation> locations, Action<TObject> callback = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IResourceLocation> | locations | locations to load. |
System.Action<TObject> | callback | This callback will be invoked once for each object that is loaded. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<System.Collections.Generic.IList<TObject>> | An async operation that will complete when all individual async load operations are complete. |
Type Parameters
Name | Description |
---|---|
TObject | Object type to load. |
ProvideScene(ISceneProvider, IResourceLocation, LoadSceneMode, Boolean, Int32)
Load a scene at a specificed resource location.
Declaration
public AsyncOperationHandle<SceneInstance> ProvideScene(ISceneProvider sceneProvider, IResourceLocation location, LoadSceneMode loadMode, bool activateOnLoad, int priority)
Parameters
Type | Name | Description |
---|---|---|
ISceneProvider | sceneProvider | The scene provider instance. |
IResourceLocation | location | The location of the scene. |
LoadSceneMode | loadMode | The load mode for the scene. |
System.Boolean | activateOnLoad | If false, the scene will be loaded in the background and not activated when complete. |
System.Int32 | priority | The priority for the load operation. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<SceneInstance> | Async operation handle that will complete when the scene is loaded. If activateOnLoad is false, then Activate() will need to be called on the SceneInstance returned. |
RegisterDiagnosticCallback(Action<AsyncOperationHandle, ResourceManager.DiagnosticEventType, Int32, Object>)
Register a handler for diagnostic events.
Declaration
[Obsolete]
public void RegisterDiagnosticCallback(Action<AsyncOperationHandle, ResourceManager.DiagnosticEventType, int, object> func)
Parameters
Type | Name | Description |
---|---|---|
System.Action<AsyncOperationHandle, ResourceManager.DiagnosticEventType, System.Int32, System.Object> | func | The event handler function. |
RegisterDiagnosticCallback(Action<ResourceManager.DiagnosticEventContext>)
Register a handler for diagnostic events.
Declaration
public void RegisterDiagnosticCallback(Action<ResourceManager.DiagnosticEventContext> func)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ResourceManager.DiagnosticEventContext> | func | The event handler function. |
Release(AsyncOperationHandle)
Release the operation associated with the specified handle
Declaration
public void Release(AsyncOperationHandle handle)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationHandle | handle | The handle to release. |
ReleaseScene(ISceneProvider, AsyncOperationHandle<SceneInstance>)
Release a scene.
Declaration
public AsyncOperationHandle<SceneInstance> ReleaseScene(ISceneProvider sceneProvider, AsyncOperationHandle<SceneInstance> sceneLoadHandle)
Parameters
Type | Name | Description |
---|---|---|
ISceneProvider | sceneProvider | The scene provider. |
AsyncOperationHandle<SceneInstance> | sceneLoadHandle | The operation handle used to load the scene. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<SceneInstance> | An operation handle for the unload. |
RemoveUpdateReciever(IUpdateReceiver)
Remove update receiver.
Declaration
public void RemoveUpdateReciever(IUpdateReceiver receiver)
Parameters
Type | Name | Description |
---|---|---|
IUpdateReceiver | receiver | The object to remove. |
StartOperation<TObject>(AsyncOperationBase<TObject>, AsyncOperationHandle)
Registers an operation with the ResourceManager. The operation will be executed when the dependency
completes.
This should only be used when creating custom operations.
Declaration
public AsyncOperationHandle<TObject> StartOperation<TObject>(AsyncOperationBase<TObject> operation, AsyncOperationHandle dependency)
Parameters
Type | Name | Description |
---|---|---|
AsyncOperationBase<TObject> | operation | The custom AsyncOperationBase object |
AsyncOperationHandle | dependency | Execution of the operation will not occur until this handle completes. A default handle can be passed if no dependency is required. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<TObject> | The AsyncOperationHandle used to access the result and status of the operation. |
Type Parameters
Name | Description |
---|---|
TObject | Object type associated with this operation. |
UnregisterDiagnosticCallback(Action<ResourceManager.DiagnosticEventContext>)
Unregister a handler for diagnostic events.
Declaration
public void UnregisterDiagnosticCallback(Action<ResourceManager.DiagnosticEventContext> func)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ResourceManager.DiagnosticEventContext> | func | The event handler function. |