protected IEnumerator LoadIcon(string in_url, ImageDownloadedCallBack success = null) { using (UnityWebRequest www = new UnityWebRequest(in_url)) { www.SetRequestHeader("Access-Control-Allow-Origin", "*"); www.downloadHandler = new DownloadHandlerTexture(); yield return(www.SendWebRequest()); RawImage.texture = ((DownloadHandlerTexture)www.downloadHandler).texture; if (success != null) { success(in_url); } } }
public void DownloadImage(string in_url, bool in_forcedDownload = false, ImageDownloadedCallBack success = null) { if (_imageURL != in_url || in_forcedDownload) { _imageURL = in_url; if (gameObject.activeInHierarchy) { if (_originalTexture == null) { _originalTexture = RawImage != null ? RawImage.texture : null; } else { RawImage.texture = _originalTexture; } if (in_url != null && in_url != "") { StartCoroutine(LoadIcon(in_url, success)); } } } }