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);
        }
        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);
            }
        }
示例#3
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();
        }
示例#4
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();
 }