Example #1
0
        /// <summary>
        /// Downloads a single face texture
        /// </summary>
        /// <param name="face"></param>
        public void DownloadFace(StreetView.Face face)
        {
            var url     = GetURL(face);
            var client  = new RestClient();
            var request = new RestRequest(url);

            client.ExecuteAsync(request, response => {
                Dispatcher.Enqueue(() => {
                    if (m_Disposed)
                    {
                        return;
                    }
                    if (response.IsSuccessful())
                    {
                        var tex = new Texture2D(1, 1, TextureFormat.RGB565, false);
                        tex.LoadImage(response.RawBytes, false);
                        tex.Apply();
                        SetFaceTexture(face, tex);
                        OnFaceTextureDownloaded?.Invoke(face, tex);
                    }
                    else
                    {
                        OnFaceTextureFailed?.Invoke(face, response.GetException().ToString());
                    }
                });
            });
        }
Example #2
0
        public void Dispose()
        {
            m_Disposed = true;

            // Unsubscribe all listeners
            foreach (var listener in OnFaceTextureFailed.GetInvocationList())
            {
                OnFaceTextureFailed -= (FaceTextureFailedHandler)listener;
            }

            foreach (var listener in OnFaceTextureDownloaded.GetInvocationList())
            {
                OnFaceTextureDownloaded -= (FaceTextureDownloadedHandler)listener;
            }

            foreach (var pair in textures)
            {
                MonoBehaviour.Destroy(pair.Value);
            }
        }