Class AsyncOperationBase<TObject>
base class for implemented AsyncOperations, implements the needed interfaces and consolidates redundant code
Inherited Members
Namespace: UnityEngine.ResourceManagement.AsyncOperations
Syntax
public abstract class AsyncOperationBase<TObject> : IAsyncOperation
Type Parameters
Name | Description |
---|---|
TObject | The type of the operation. |
Constructors
AsyncOperationBase()
Basic constructor for AsyncOperationBase.
Declaration
protected AsyncOperationBase()
Fields
HasExecuted
Declaration
protected bool HasExecuted
Field Value
Type | Description |
---|---|
Boolean |
Properties
DebugName
A custom operation should override this method to provide a debug friendly name for the operation.
Declaration
protected virtual string DebugName { get; }
Property Value
Type | Description |
---|---|
String |
IsRunning
True if the current op has begun but hasn't yet reached completion. False otherwise.
Declaration
public bool IsRunning { get; }
Property Value
Type | Description |
---|---|
Boolean |
Progress
A custom operation should override this method to return the progress of the operation.
Declaration
protected virtual float Progress { get; }
Property Value
Type | Description |
---|---|
Single | Progress of the operation. Value should be between 0.0f and 1.0f |
Result
Accessor to Result of the operation.
Declaration
public TObject Result { get; set; }
Property Value
Type | Description |
---|---|
TObject |
Methods
Complete(TObject, Boolean, String)
Complete the operation and invoke events.
Declaration
public void Complete(TObject result, bool success, string errorMsg)
Parameters
Type | Name | Description |
---|---|---|
TObject | result | The result object for the operation. |
Boolean | success | True if successful or if the operation failed silently. |
String | errorMsg | The error message if the operation has failed. |
Remarks
An operation is considered to have failed silently if success is true and if errorMsg isn't null or empty. The exception handler will be called in cases of silent failures. Any failed operations will call Release on any dependencies that succeeded.
Complete(TObject, Boolean, String, Boolean)
Complete the operation and invoke events.
Declaration
public void Complete(TObject result, bool success, string errorMsg, bool releaseDependenciesOnFailure)
Parameters
Type | Name | Description |
---|---|---|
TObject | result | The result object for the operation. |
Boolean | success | True if successful or if the operation failed silently. |
String | errorMsg | The error message if the operation has failed. |
Boolean | releaseDependenciesOnFailure | When true, failed operations will release any dependencies that succeeded. |
Remarks
An operation is considered to have failed silently if success is true and if errorMsg isn't null or empty. The exception handler will be called in cases of silent failures.
Destroy()
This will be called by the resource manager when the reference count of the operation reaches zero. This method should not be called manually. A custom operation should override this method and release any held resources
Declaration
protected virtual void Destroy()
Execute()
This will be called by the resource manager after all dependent operation complete. This method should not be called manually. A custom operation should override this method and begin work when it is called.
Declaration
protected abstract void Execute()
GetDependencies(List<AsyncOperationHandle>)
A custom operation should override this method to provide a list of AsyncOperationHandles that it depends on.
Declaration
protected virtual void GetDependencies(List<AsyncOperationHandle> dependencies)
Parameters
Type | Name | Description |
---|---|---|
List<AsyncOperationHandle> | dependencies | The list that should be populated with dependent AsyncOperationHandles. |
ToString()
Converts the information about the operation to a formatted string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | Returns the information about the operation. |
Overrides
WaitForCompletion()
Synchronously complete the async operation.
Declaration
public void WaitForCompletion()