Provides a cross-platform interface to display web contents inside your application.
More...
|
void | Show () |
| Displays the webview on the top of Unity view.
|
|
void | Hide () |
| Hides the web view.
|
|
void | LoadURL (URLString url) |
| Connects to a given URL and asynchronously loads the content.
|
|
void | LoadHtmlString (string htmlString, URLString? baseURL=null) |
| Loads the webpage contents.
|
|
void | LoadData (byte[] data, string mimeType, string textEncodingName, URLString? baseURL=null) |
| Loads the webpage contents from specified file.
|
|
void | Reload () |
| Reloads the current page.
|
|
void | StopLoading () |
| Stops loading the current page contents.
|
|
void | RunJavaScript (string script, EventCallback< WebViewRunJavaScriptResult > callback) |
| Executes a JavaScript string.
|
|
void | AddURLScheme (string urlScheme) |
| Registers the specified scheme, after which web view will start to listen for custom URL.
|
|
void | ClearCache () |
| Clears all stored cached URL responses.
|
|
|
string | URL [get] |
| The active URL. (read-only)
|
|
string | Title [get] |
| The page title. (read-only)
|
|
Rect | Frame [get, set] |
| The frame rectangle describes the webview’s position and size.
|
|
WebViewStyle | Style [get, set] |
| An enum value that determines the appearence of webview.
|
|
bool | AutoShowOnLoadFinish [get, set] |
| A boolean value indicating whether webview can auto show itself when load request is finished.
|
|
bool | ScalesPageToFit [get, set] |
| A boolean value indicating whether web view scales webpages to fit the view and the user can change the scale.
|
|
bool | CanBounce [get, set] |
| A Boolean value that controls whether the web view bounces past the edge of content and back again.
|
|
Color | BackgroundColor [get, set] |
| The background color of the webview.
|
|
double | Progress [get] |
| The value indicates the progress of load request.
|
|
bool | IsLoading [get] |
| A boolean value indicating whether this webview is loading content.
|
|
bool | JavaScriptEnabled [get, set] |
| A boolean value indicating whether this webview allows java script execution.
|
|
|
static Callback< WebView > | OnShow |
| Event that will be called when webview is first displayed.
|
|
static Callback< WebView > | OnHide |
| Event that will be called when webview is dismissed.
|
|
static Callback< WebView > | OnLoadStart |
| Event that will be called when web view begins load request.
|
|
static EventCallback< WebView > | OnLoadFinish |
| Event that will be called when web view has finished loading.
|
|
static Callback< string > | OnURLSchemeMatchFound |
| Event that will be called when web view has finished loading.
|
|
To do so, drag and drop the WebView prefab into scene heirarchy, which is placed under folder Assets/VoxelBusters/NativePlugins/Prefab. And then send it a request to display web content. You can also use this class to move back and forward in the history, just like web browser by setting control type to eWebviewControlType.TOOLBAR
.
The following code illustrates how to load webpage using web view.
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
private void Start()
{
m_webView.SetFullScreen();
}
private void OnEnable()
{
WebView.OnShow += OnShow;
WebView.OnHide += OnHide;
WebView.OnLoadStart += OnLoadStart;
WebView.OnLoadFinish += OnLoadFinish;
}
private void OnDisable()
{
WebView.OnShow -= OnShow;
WebView.OnHide -= OnHide;
WebView.OnLoadStart -= OnLoadStart;
WebView.OnLoadFinish -= OnLoadFinish;
}
private void OnShow(
WebView result)
{
if (m_webView == result)
{
Debug.Log("Showing webview.");
}
}
private void OnHide(
WebView result)
{
if (m_webView == result)
{
Debug.Log("Hiding webview.");
}
}
private void OnLoadStart(
WebView result)
{
if (m_webView == result)
{
Debug.Log(
"Started loading request with url:" + m_webView.
URL);
}
}
private void OnLoadFinish(
WebView result, Error error)
{
if (m_webView == result)
{
if (error == null)
{
Debug.Log("Webview did finish loading request successfully.");
} <br>
else
{
Debug.Log("Webview did fail to load request. Error: " + error.Description);
}
}
}
}
Provides a cross-platform interface to display web contents inside your application.
Definition WebView.cs:105
static WebView CreateInstance(WebViewUnitySettings settings=null)
Initializes a new instance of the MessageComposer class.
Definition WebView.cs:439
void LoadURL(URLString url)
Connects to a given URL and asynchronously loads the content.
Definition WebView.cs:541
string URL
The active URL. (read-only)
Definition WebView.cs:152
Namespace for essential kit features. You need to import this namespace along with VoxelBusters....
Definition AddressBook.cs:8
Struct value to represent the location of a resource, such as an item on a remote server or the path ...
Definition URLString.cs:12