Exemplo n.º 1
0
 /// <summary> Marks the request with the error status. The request will be removed from the pool. </summary>
 public void SetError(Error error)
 {
     this.error = error;
     if (error)
     {
         status = Status.Error;
         NotificationsPopup.Add(error.ToString(), MessageType.Error, notificationLink);
     }
 }
Exemplo n.º 2
0
    private static void OnDownloaded(AsyncRequest request, byte[] data, Error error)
    {
        //Handle error
        if (error)
        {
            request.SetError(error);
            return;
        }

        //Download completed
        else
        {
            request.status = Status.WritingAsset;
        }

        //Write file
        string savePath = request.saveDirectory + "/" + request.fileName;

        File.WriteAllBytes(savePath, data);

        //Import asset
        savePath = Utils.LocalPath(savePath);
        AssetDatabase.ImportAsset(savePath, ImportAssetOptions.ForceUpdate);
        if (request.notificationLink == null)
        {
            request.notificationLink = AssetDatabase.LoadAssetAtPath <AudioClip>(savePath);
        }

        //Send notification
        NotificationsPopup.Add("Download completed\n" + request.requestName, MessageType.Info, request.notificationLink);

        //Delete clip if needed
        if (!request.deleteClipAtEnd)
        {
            request.status = Status.Completed;
        }
        else
        {
            request.status      = Status.SendRequestDeletion;
            request.currentTask = APIBridge.DeleteClip(request.clipUUID, (string content, Error deleteError) =>
            {
                if (deleteError)
                {
                    request.SetError(deleteError);
                }
                else
                {
                    request.status = Status.Completed;
                }
            });
        }
    }