/// <summary> /// Synchronously complete the async operation. /// </summary> /// <returns>The result of the operation or null.</returns> public TObject WaitForCompletion() { #if !UNITY_2021_1_OR_NEWER AsyncOperationHandle.IsWaitingForCompletion = true; try { if (IsValid()) { InternalOp.WaitForCompletion(); } if (IsValid()) { return(Result); } } finally { AsyncOperationHandle.IsWaitingForCompletion = false; m_InternalOp?.m_RM?.Update(Time.deltaTime); } #else if (IsValid()) { InternalOp.WaitForCompletion(); } m_InternalOp?.m_RM?.Update(Time.deltaTime); if (IsValid()) { return(Result); } #endif return(default(TObject)); }
/// <summary> /// Synchronously complete the async operation. /// </summary> /// <returns>The result of the operation or null.</returns> public TObject WaitForCompletion() { if(IsValid()) InternalOp.WaitForCompletion(); if(IsValid()) return Result; return default(TObject); }
internal DownloadStatus InternalGetDownloadStatus(HashSet <object> visited) { if (visited == null) { visited = new HashSet <object>(); } return(visited.Add(InternalOp) ? InternalOp.GetDownloadStatus(visited) : new DownloadStatus() { IsDone = IsDone }); }
/// <summary> /// Synchronously complete the async operation. /// </summary> /// <returns>The result of the operation or null.</returns> public TObject WaitForCompletion() { if (IsValid()) { InternalOp.WaitForCompletion(); } if (IsValid()) { return(Result); } return(default(TObject)); }
/// <summary> /// Acquire a new handle to the internal operation. This will increment the reference count, therefore the returned handle must also be released. /// </summary> /// <returns>A new handle to the operation. This handle must also be released.</returns> internal AsyncOperationHandle <TObject> Acquire() { InternalOp.IncrementReferenceCount(); return(this); }
/// <summary> /// Release the handle. If the internal operation reference count reaches 0, the resource will be released. /// </summary> internal void Release() { InternalOp.DecrementReferenceCount(); m_InternalOp = null; }
/// <summary> /// Set the func for handling progress requests. /// </summary> /// <param name="callback">The callback function.</param> public void SetProgressCallback(Func <float> callback) { InternalOp.SetProgressCallback(callback); }
/// <summary> /// Get the depedency objects. /// </summary> /// <param name="list">The list of dependecies to fill in.</param> public void GetDependencies(IList <object> list) { InternalOp.GetDependencies(list); }
/// <summary> /// Get a specific dependency object. /// </summary> /// <typeparam name="TDepObject">The dependency type.</typeparam> /// <param name="index">The index of the dependency.</param> /// <returns>The dependency object.</returns> public TDepObject GetDependency <TDepObject>(int index) { return(InternalOp.GetDependency <TDepObject>(index)); }
/// <summary> /// Called to complete the operation. /// </summary> /// <typeparam name="T">The type of object requested.</typeparam> /// <param name="result">The result object.</param> /// <param name="status">True if the operation was successful, false otherwise.</param> /// <param name="exception">The exception if the operation failed.</param> public void Complete <T>(T result, bool status, Exception exception) { InternalOp.ProviderCompleted <T>(result, status, exception); }
/// <summary> /// Set the func for handling a request to wait for the completion of the operation /// </summary> /// <param name="callback">The callback function.</param> public void SetWaitForCompletionCallback(Func <bool> callback) { InternalOp.SetWaitForCompletionCallback(callback); }
/// <summary> /// Set the func for handling download progress requests. /// </summary> /// <param name="callback">The callback function.</param> public void SetDownloadProgressCallbacks(Func <DownloadStatus> callback) { InternalOp.SetDownloadProgressCallback(callback); }
/// <summary> /// Get dependency operations. /// </summary> /// <param name="deps">The list of AsyncOperationHandles that are dependencies of a given AsyncOperationHandle</param> public void GetDependencies(List <AsyncOperationHandle> deps) { InternalOp.GetDependencies(deps); }