diff --git a/Assets/MainScene.unity b/Assets/MainScene.unity index 98f3a5f..f6a5e2f 100644 --- a/Assets/MainScene.unity +++ b/Assets/MainScene.unity @@ -25699,7 +25699,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -2.4958083e-10} + m_AnchoredPosition: {x: 0, y: -0.0000021741748} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1371052592 @@ -26384,7 +26384,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 275.22113, y: 60} + m_AnchoredPosition: {x: 134.06734, y: 60} m_SizeDelta: {x: 0, y: 150} m_Pivot: {x: 1, y: 1} --- !u!114 &1433522477 diff --git a/Assets/Scripts/GoogleMapDisplay.cs b/Assets/Scripts/GoogleMapDisplay.cs index 2be13b5..cd95479 100644 --- a/Assets/Scripts/GoogleMapDisplay.cs +++ b/Assets/Scripts/GoogleMapDisplay.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using System; +using UnityEngine.Networking; public class GoogleMapDisplay : MonoBehaviour { public static GoogleMapDisplay instance; @@ -154,25 +155,34 @@ public void ChangeMapZoom() { IEnumerator DownloadMap(Action action, OneRequest request) { string url = ReturnApiUrl(request); - using (WWW www = new WWW(url)) { - yield return www; - Sprite sprite = Sprite.Create(www.texture, + UnityWebRequest www = UnityWebRequestTexture.GetTexture(url); + yield return www.SendWebRequest(); + + if (www.isNetworkError || www.isHttpError) { + Debug.LogError("DOWNLOAD MAP ERROR: " + www.error); + } else { + Texture2D texture = ((DownloadHandlerTexture)www.downloadHandler).texture; + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, 640, 640), new Vector2(0.5f, 0.5f)); - action.Invoke(sprite, request); } } IEnumerator DownloadMapRetina(Action action, OneRequest request) { + string url = ReturnApiUrl(request); - using (WWW www = new WWW(url)) { - yield return www; - Sprite sprite = Sprite.Create(www.texture, + UnityWebRequest www = UnityWebRequestTexture.GetTexture(url); + yield return www.SendWebRequest(); + + if (www.isNetworkError || www.isHttpError) { + Debug.LogError("DOWNLOAD MAP RETINA ERROR: " + www.error); + } else { + Texture2D texture = ((DownloadHandlerTexture)www.downloadHandler).texture; + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, 1280, 1280), new Vector2(0.5f, 0.5f), 200); - action.Invoke(sprite, request); } } diff --git a/Assets/Scripts/GooglePhotosApi.cs b/Assets/Scripts/GooglePhotosApi.cs index 18e891a..ef124e7 100644 --- a/Assets/Scripts/GooglePhotosApi.cs +++ b/Assets/Scripts/GooglePhotosApi.cs @@ -366,24 +366,19 @@ void AddPhotosToTimeLineItems(GooglePhotosResponse response) { //} } public IEnumerator DownloadImage(string url, Image targetImage) { - // Start a download of the given URL - var www = new WWW(url); - // wait until the download is done - yield return www; - // Create a texture in DXT1 format - Texture2D texture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.DXT1, false); - - // assign the downloaded image to sprite - www.LoadImageIntoTexture(texture); - Rect rec = new Rect(0, 0, texture.width, texture.height); - Sprite spriteToUse = Sprite.Create(texture, rec, new Vector2(0.5f, 0.5f), 200); - - targetImage.sprite = spriteToUse; - - www.Dispose(); - www = null; - loadPhotosButtonText.text = "Load photos"; + UnityWebRequest www = UnityWebRequestTexture.GetTexture(url); + yield return www.SendWebRequest(); + if (www.isNetworkError || www.isHttpError) { + Debug.LogError("DOWNLOAD GOOGLE IMAGE ERROR: " + www.error); + } else { + Texture2D texture = ((DownloadHandlerTexture)www.downloadHandler).texture; + Sprite sprite = Sprite.Create(texture, + new Rect(0, 0, texture.width, texture.height), + new Vector2(0.5f, 0.5f), 200); + targetImage.sprite = sprite; + loadPhotosButtonText.text = "Load photos"; + } } }