private void Start()
        {
            httpClient = new UnityHttpClient();
            httpClient.DownloadInProgress.AddListener((UnityHttpClient client, DownloadInProgressEventArgs e) =>
            {
                float progress = (float)e.BytesRead / e.TotalLength;
                Debug.Log(progress);
            });

            httpClient.DownloadCompleted.AddListener((UnityHttpClient client, DownloadCompletedEventArgs e) =>
            {
                UnityHttpResponse resp = (UnityHttpResponse)e.Response;
                Debug.LogFormat("HTTP Status Code: {0}", resp.StatusCode);
                Debug.LogFormat("HTTP Response Data: {0}", resp.Text);
                IntegrationTest.Pass();
            });

            httpClient.ErrorReceived.AddListener((UnityHttpClient client, HttpErrorReceivedEventArgs e) =>
            {
                Debug.LogError(e.ErrorMessage);
                IntegrationTest.Fail();
            });

            httpClient.ExceptionCaught.AddListener((UnityHttpClient client, HandledExceptionEventArgs e) =>
            {
                Debug.LogException(e.Exception);
                IntegrationTest.Fail();
            });

            UnityHttpRequest req = new UnityHttpRequest("http://www.baidu.com/");

            httpClient.SendRequest(req);
        }
Example #2
0
 private void OnDisable()
 {
     if (client != null)
     {
         client.Dispose();
         client = null;
     }
 }
 private void OnDisable()
 {
     if (httpClient != null)
     {
         httpClient.Dispose();
         httpClient = null;
     }
 }
        private void OnResult(UnityHttpClient httpClient, UnityHttpResponse response)
        {
            UnityHttpResponseAudioClip audioResp = (UnityHttpResponseAudioClip)response;
            AudioClip clip = audioResp.AudioClip;

            audioGameObject = new GameObject();
            AudioSourcePlayer player = audioGameObject.AddComponent <AudioSourcePlayer>();

            if (player)
            {
                player.AudioPlayCompleted.AddListener((AudioSourcePlayer p, EventArgs e) =>
                {
                    Destroy(audioGameObject);
                    IntegrationTest.Pass();
                });
                player.PlayAudio(clip);
            }
        }
Example #5
0
        private void OnResult(UnityHttpClient httpClient, UnityHttpResponse response)
        {
            UnityHttpResponseTexture respTex = (UnityHttpResponseTexture)response;
            Texture2D tex = respTex.Texture;

            if (tex != null)
            {
                RawImage img = FindObjectOfType <RawImage>();

                if (img)
                {
                    img.texture = tex;
                }

                IntegrationTest.Pass();
                return;
            }

            IntegrationTest.Fail();
        }
Example #6
0
 private void OnError(UnityHttpClient httpClient, string errorMessage)
 {
     Debug.LogError(errorMessage);
     IntegrationTest.Fail(gameObject, errorMessage);
 }
Example #7
0
 // Use this for initialization
 private void Start()
 {
     client = UnityHttpClient.GetTexture("http://mat1.gtimg.com/www/images/qq2012/qqLogoFilter.png", true, OnResult, OnError);
 }
Example #8
0
 private void OnResult(UnityHttpClient httpClient, UnityHttpResponse response)
 {
     Debug.LogFormat("HTTP Status Code: {0}", response.StatusCode);
     Debug.LogFormat("HTTP Response Data: {0}", response.Text);
     IntegrationTest.Pass();
 }
Example #9
0
 // Use this for initialization
 private void Start()
 {
     client = UnityHttpClient.Get("http://www.baidu.com/", OnResult, OnError);
 }
 // Use this for initialization
 private void Start()
 {
     client = UnityHttpClient.GetAudioClip("http://fjdx.sc.chinaz.com/Files/DownLoad/sound1/201707/9001.wav", AudioType.WAV, OnResult, OnError);
 }