Ejemplo n.º 1
0
        /// <summary>
        /// Setup request.
        /// </summary>
        public void Setup()
        {
            // Determine which request to use.
            switch (requestInfo.RequestType)
            {
            case Netko.RequestType.Get:
                UnityRequest = UnityWebRequest.Get(requestInfo.Url.GetUriEscaped());
                break;

            case Netko.RequestType.Post:
                UnityRequest = UnityWebRequest.Post(requestInfo.Url.GetUriEscaped(), requestInfo.Form);
                if (requestInfo.UploadHandler != null)
                {
                    UnityRequest.uploadHandler = requestInfo.UploadHandler;
                }
                break;

            case Netko.RequestType.Delete:
                UnityRequest = UnityWebRequest.Delete(requestInfo.Url.GetUriEscaped());
                break;

            case Netko.RequestType.Put:
                UnityRequest = UnityWebRequest.Put(requestInfo.Url.GetUriEscaped(), requestInfo.PutData);
                break;

            case Netko.RequestType.Head:
                UnityRequest = UnityWebRequest.Head(requestInfo.Url.GetUriEscaped());
                break;

            case Netko.RequestType.Audio:
                UnityRequest = UnityWebRequest.GetAudioClip(requestInfo.Url.GetUriEscaped(), requestInfo.AudioType);
                break;

            case Netko.RequestType.AudioStream:
                AudioRequest = new AudioStreamRequest(requestInfo.Url.GetUriEscaped(true));
                break;

            case Netko.RequestType.Texture:
                UnityRequest = UnityWebRequest.GetTexture(
                    requestInfo.Url.GetUriEscaped(), requestInfo.TextureNonReadable
                    );
                break;

            case Netko.RequestType.AssetBundle:
                UnityRequest = UnityWebRequest.GetAssetBundle(
                    requestInfo.Url.GetUriEscaped(), requestInfo.AssetBundleVersion, requestInfo.AssetBundleCRC
                    );
                break;
            }

            // Initialize variables
            SetError(null);
            isProcessing = false;
            TimeOutTime  = requestInfo.TimeOut;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Terminates requests.
 /// </summary>
 public void Terminate()
 {
     if (UnityRequest != null)
     {
         UnityRequest.Abort();
     }
     else if (AudioRequest != null)
     {
         AudioRequest.Dispose();
     }
     UnityRequest = null;
     AudioRequest = null;
 }