Categories

Using the prefab

If you use a completed prefab WellWebViewExample. prefab, you need to set a few minimum parameters.The window with default parameters looks like this:

Let's look at the parameters in more detail:

Url - Url that loads at startup.

Show On Start - Show the web view at startup. If not, then you need to manually call the Show().

Full Screen - Sets the full-screen mode, if enabled, automatically adjusts the web view to display on the full screen of the device.

Tool Bar - Drop-down list with options for displaying the toolbar (top, bottom, disable).Only for iOS.

Target Rect - Sets the RectTransform that the web view will try to use as a reference(in this case, full-screen mode is disabled, and the manually set VisibleRect is ignored). Because in this mode, the web view will copy the position and size of this object.

Visible Rect - Sets the size and position of the web view at the start show(when fullscreen mode is turned off and targetRect == null).

Writing code

In order to create a web view manually,without using a prefab and customize it to your needs. You need to decide what functions are needed,the minimum necessary step is this code:

public class MyScript : MonoBehaviour
{
public WellWebView WebView;

private void Start()
{
WellWebView.SetAllowJavaScript(true);
WellWebView.SetJavaScriptCanOpenWindowsAutomatically(true);
WebView = WellWebView.CreateWebView();
WebView.OnFinishedInit += (RaisedWebView) =>
{
// The web view is fully initialized, and you can call the web view methods
WebView.SetSupportMultipleWindows(true);
WebView.Android.SetUseWideViewPort(true);
WebView.Android.SetLoadWithOverviewMode(true);
WebView.IOS.AllowBackForwardNavigationGestures(true);
WebView.LoadUrl("https://example.com");
WebView.Show();
};
WebView.Init();
}
}