public void StartDownload() { URL _URL; // Check type of url if (m_URLString.StartsWith("http")) { _URL = URL.URLWithString(m_URLString); } else { _URL = URL.FileURLWithPath(m_URLString); } // Download image from given path DownloadTexture _newDownload = new DownloadTexture(_URL, true, true); _newDownload.OnCompletion = (Texture2D _texture, string _error) => { Debug.Log(string.Format("[DownloadTextureDemo] Texture download completed. Error= {0}.", _error.GetPrintableString())); if (_texture != null) { m_renderer.sharedMaterial.mainTexture = _texture; } }; // Start download _newDownload.StartRequest(); }
public void StartDownload() { URL _URL; // Check type of url if (m_URLString.StartsWith("http")) { _URL = URL.URLWithString(m_URLString); } else { _URL = URL.FileURLWithPath(m_URLString); } // Download image from given path DownloadTexture _newDownload = new DownloadTexture(_URL, true, true); _newDownload.OnCompletion = (Texture2D _texture, string _error) => { if (string.IsNullOrEmpty(_error)) { m_renderer.sharedMaterial.mainTexture = _texture; } else { Debug.LogError("[DownloadTextureDemo] Error=" + _error); } }; // Start download _newDownload.StartRequest(); }
/// <summary> /// Loads the webpage contents from specified file. /// </summary> /// <param name="_HTMLFilePath">Path of the target file, to use as contents of the webpage.</param> /// <param name="_baseURL">The base URL for the content.</param> public void LoadHTMLStringContentsOfFile(string _HTMLFilePath, string _baseURL) { DownloadAsset _request = new DownloadAsset(URLAddress.FileURLWithPath(_HTMLFilePath), true); _request.OnCompletion = (WWW _www, string _error) => { if (string.IsNullOrEmpty(_error)) { LoadHTMLString(_www.text, _baseURL); } else { Console.LogError(Constants.kDebugTag, "[WebView] The operation could not be completed. Error=" + _error); return; } }; _request.StartRequest(); }