public static void SetUserAgent(string value) { #if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR UniWebViewPlugin.SetUserAgent(value); #endif }
/// <summary> /// Stop loading the current request. It will do nothing if the webpage is not loading. /// </summary> public void Stop() { UniWebViewPlugin.Stop(gameObject.name); }
/// <summary> /// Go to the previous page if there is any one. /// </summary> public void GoBack() { UniWebViewPlugin.GoBack(gameObject.name); }
/// <summary> /// Adds the URL scheme. After be added, all link of this scheme will send a message when clicked. /// </summary> /// <param name="scheme">Scheme.</param> /// <description> /// The scheme should not contain "://". For example, if you want to receive a url like "xyz://mydomian.com", you can pass "xyz" here. /// </description> public void AddUrlScheme(string scheme) { UniWebViewPlugin.AddUrlScheme(gameObject.name, scheme); }
/// <summary> /// Set the background of webview to transparent. /// </summary> /// <description> /// In iOS, there is a grey background in webview. If you don't want it, just call this method to set it transparent. /// There is no way to set Windows Phone 8 background to transparent, so this method will do noting on Windows Phone. /// </description> public void SetTransparentBackground(bool transparent = true) { UniWebViewPlugin.TransparentBackground(gameObject.name, transparent); }
/// <summary> /// Set the label text for the spinner showing when webview loading. /// The default value is "Loading..." /// </summary> /// <param name="text">Text.</param> /// <description> /// There is no text for Windows Phone spinner, so it will do noting for it. /// </description> public void SetSpinnerLabelText(string text) { UniWebViewPlugin.SetSpinnerText(gameObject.name, text); }
/// <summary> /// Determines whether this webview can go forward. /// </summary> /// <returns><c>true</c> if this instance can go forward, which means the user did at least once back; /// otherwise, <c>false</c>.</returns> public bool CanGoForward() { return(UniWebViewPlugin.CanGoForward(gameObject.name)); }
/// <summary> /// Clean the cache of this UniWebView. /// </summary> public void CleanCache() { UniWebViewPlugin.CleanCache(gameObject.name); }
/// <summary> /// Set the background color of webview. /// </summary> /// <description> /// Set the background color of the webview. In iOS, it will only take in action when the web page has no background color from css. /// There is no way to set Windows Phone 8, so this method will do noting on Windows Phone. /// And in OSX Editor, it is limited and can be only used to set white or clear background. /// </description> public void SetBackgroundColor(Color color) { UniWebViewPlugin.SetBackgroundColor(gameObject.name, color.r, color.g, color.b, color.a); }
/// <summary> /// Determines whether the webview can go back. /// </summary> /// <returns><c>true</c> if this instance can go back, which means there is at least one page in the navigation stack below; /// otherwise, <c>false</c>.</returns> public bool CanGoBack() { return(UniWebViewPlugin.CanGoBack(gameObject.name)); }
/// <summary> /// Set web content could be debug or not. Only works for Android. /// </summary> /// <description> /// You can enable Remote Debugging for Android devices by calling this method and passing true. See Google's /// Remote Debugging Android Devices documentation for more about it. /// https://developers.google.com/web/tools/chrome-devtools/debug/remote-debugging/remote-debugging /// /// This method will do nothing for iOS or editor. /// </description> /// <param name="enabled">Whether this page could be debug or not.</param> public static void SetWebContentsDebuggingEnabled(bool enabled) { #if UNITY_ANDROID && !UNITY_EDITOR UniWebViewPlugin.SetWebContentsDebuggingEnabled(enabled); #endif }
/// <summary> /// Set to load with overview mode or not. /// </summary> /// <param name="overview"> /// If set to <c>true</c>, use overview mode to load the page. /// </param> /// <description> /// This method only works for Android. If you need to load your page with overview mode, you may /// want to enable it before you loading and showing your page. /// </description> public void LoadWithOverviewMode(bool overview) { #if UNITY_ANDROID && !UNITY_EDITOR UniWebViewPlugin.LoadWithOverviewMode(gameObject.name, overview); #endif }
/// <summary> /// Set the text in Done button of tool bar in iOS. /// User could use this button in iOS to close the web view. By default, "Done" will be shown for this button. /// If you want to change the text of tool bar done button for the webview, you have to call it before creating the UniWebView instance. /// This method only works for iOS. See <seealso cref="ShowToolBar"/>. /// </summary> /// <param name="text">The text you want to show for the Done button. Set it to null will reset it to "Done".</param> public static void SetDoneButtonText(string text) { #if UNITY_IOS && !UNITY_EDITOR UniWebViewPlugin.SetDoneButtonText(text); #endif }
/// <summary> /// Send a piece of javascript to the web page and evaluate (execute) it. /// </summary> /// <param name="javaScript">A single javascript method call to be sent to and executed in web page</param> /// <description> /// Although you can write complex javascript code and evaluate it at once, a suggest way is calling this method with a single js method name. /// The webview will try evaluate (execute) the javascript. When it finished, OnEvalJavaScriptFinished will be raised with the result. /// You can add your js function to the html page by referring to the js file in your html page, or add it by using AddJavaScript(string javaScript) method. /// </description> public void EvaluatingJavaScript(string javaScript) { UniWebViewPlugin.EvaluatingJavaScript(gameObject.name, javaScript); }
/// <summary> /// Add a url to white list of permission request trust sites. /// </summary> /// <description> /// This method only works in Android. In Android, if you request audio or video accessibility from web page, /// you should add the site url to a white list by using this method, or it will not be granted to use those protected resources. /// There is no need to call it in iOS, and this method will do nothing in platforms other than Android. /// For more about Android protected permission, see https://developer.android.com/reference/android/webkit/PermissionRequest.html. /// </description> /// <param name="url">URL.</param> public void AddPermissionRequestTrustSite(string url) { #if UNITY_ANDROID && !UNITY_EDITOR UniWebViewPlugin.AddPermissionRequestTrustSite(gameObject.name, url); #endif }
/// <summary> /// Add some javascript to the web page. /// </summary> /// <param name="javaScript">Some javascript code you want to add to the page.</param> /// <description> /// This method will execute the input javascript code without raising an /// OnEvalJavaScriptFinished event. You can use this method to add some customized js /// function to the web page, then use EvaluatingJavaScript(string javaScript) to execute it. /// This method will add js in a async way in Android, so you should call it earlier than EvaluatingJavaScript /// </description> public void AddJavaScript(string javaScript) { UniWebViewPlugin.AddJavaScript(gameObject.name, javaScript); }
/// <summary> /// Set user agent string for webview. This method has no effect on the webviews which are already initiated. /// The user agent of a UniWebView component can not be changed once it is created. /// If you want to change the user agent for the webview, you have to call it before creating the UniWebView instance. /// </summary> /// <param name="value">The value user agent should be. Set it to null will reset the user agent to the default one.</param> public static void SetUserAgent(string value) { UniWebViewPlugin.SetUserAgent(value); }
/// <summary> /// Clean the cookie using in the app. /// </summary> /// <param name="key">The key under which you want to clean the cache.</param> /// <description> /// Try to clean cookies under the specified key using in the app. /// If you leave the key as null or send an empty string as key, all cache will be cleared. /// This method will clear the cookies in memory and try to /// sync the change to disk. The memory opreation will return /// right away, but the disk operation is async and could take some time. /// Caution, in Android, there is no way to remove a specified cookie. /// So this method will call setCookie method with the key to set /// it to an empty value instead. Please refer to Android /// documentation on CookieManager for more information. /// The key parameter will be ignored at all on Windows Phone 8. All cookie will be cleared. /// </description> public void CleanCookie(string key = null) { UniWebViewPlugin.CleanCookie(gameObject.name, key); }
/// <summary> /// Reset the user agent of webview. This method has no effect on the webviews which are already initiated. /// The user agent of a UniWebView component can not be changed once it is created. /// If you want to set user agent, use the <see cref="SetUserAgent"/> method. /// </summary> public static void ResetUserAgent() { UniWebViewPlugin.SetUserAgent(null); }
/// <summary> /// Set if a default spinner should show when loading the webpage. /// </summary> /// <description> /// The default value is true, which means a spinner will show when the webview is on, and it is loading some thing. /// The spinner contains a label and you can set a message to it. <see cref=""/> /// You can set it false if you do not want a spinner show when loading. /// A progress bar will be used in Windows Phone instead of a spinner. /// </description> /// <param name="show">If set to <c>true</c> show.</param> public void SetShowSpinnerWhenLoading(bool show) { UniWebViewPlugin.SetSpinnerShowWhenLoading(gameObject.name, show); }
/// <summary> /// Load the url set in <seealso cref="url"/> property of this UniWebView. /// </summary> public void Load() { string loadUrl = String.IsNullOrEmpty(url) ? "about:blank" : url.Trim(); UniWebViewPlugin.Load(gameObject.name, loadUrl); }
/// <summary> /// Set to use wide view port support or not. /// </summary> /// <param name="use">If set to <c>true</c> use view port tag in the html to determine the layout.</param> /// <description> /// This method only works (and be necessary) for Android. If you are using viewport tag in you page, you may /// want to enable it before you loading and showing your page. /// </description> public void SetUseWideViewPort(bool use) { #if UNITY_ANDROID && !UNITY_EDITOR UniWebViewPlugin.SetUseWideViewPort(gameObject.name, use); #endif }
/// <summary> /// Load a HTML string. /// </summary> /// <param name="htmlString">The content HTML string for the web page.</param> /// <param name="baseUrl">The base URL in which the webview should to refer other resources</param> /// <description> /// If you want to specify a local baseUrl, you need to encode it to proper format. /// See the "Can I load some html string by using UniWebView?" section in FAQ page (http://uniwebview.onevcat.com/faqs.html) for more. /// </description> public void LoadHTMLString(string htmlString, string baseUrl) { UniWebViewPlugin.LoadHTMLString(gameObject.name, htmlString, baseUrl); }
/// <summary> /// Go to the next page if there is any one. /// </summary> public void GoForward() { UniWebViewPlugin.GoForward(gameObject.name); }
/// <summary> /// Reload current page. /// </summary> public void Reload() { UniWebViewPlugin.Reload(gameObject.name); }
/// <summary> /// Removes the URL scheme. After be removed, this kind of url will be handled by the webview. /// </summary> /// <param name="scheme">Scheme.</param> public void RemoveUrlScheme(string scheme) { UniWebViewPlugin.RemoveUrlScheme(gameObject.name, scheme); }
public static void SetCookie(string url, string cookie) { #if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR UniWebViewPlugin.SetCookie(url, cookie); #endif }