There are two different 3D WebView packages for Android:
You can read a detailed comparison of the two packages here. If desired, you can use both 3D WebView for Android packages together. For example, you might do this if you want some of your app's webviews to use Gecko and some of them to use the non-Gecko package.
First, start by importing both packages into the same project. Both packages must be of the same minor version, like described here. When both packages are installed in the same project, WebViewPrefab and CanvasWebViewPrefab use the Gecko package by default. However, if you want to make a prefab in your scene use the non-Gecko package instead, you can do that by passing the preferredPlugins option to WebViewPrefab.SetOptionsForInitialization() before the prefab initializes, like this:
using System;
using UnityEngine;
using Vuplex.WebView;
class SetPreferredPlugin : MonoBehaviour {
// IMPORTANT: With this approach, you must set your WebViewPrefab or CanvasWebViewPrefab to inactive
// in the scene hierarchy so that this script can manually activate it. Otherwise, this
// script won't be able to call SetOptionsForInitialization() before the prefab initializes.
//
// TODO: Set this webViewPrefab field to the inactive WebViewPrefab or CanvasWebViewPrefab in your scene
// via the Editor's Inspector tab.
public BaseWebViewPrefab webViewPrefab;
void Awake() {
if (webViewPrefab.gameObject.activeInHierarchy) {
throw new Exception("The WebViewPrefab object is active in the Editor's scene view. Please set it to inactive so that this script can manually activate it.");
}
webViewPrefab.gameObject.SetActive(true);
webViewPrefab.SetOptionsForInitialization(new WebViewOptions {
preferredPlugins = new WebPluginType[] { WebPluginType.Android }
});
}
}
Or if you want to dynamically instantiate a prefab that uses the non-Gecko package, you can pass the preferredPlugins option to WebViewPrefab.Instantiate(), like this:
var prefab = WebViewPrefab.Instantiate(width, height, new WebViewOptions {
preferredPlugins = new WebPluginType[] { WebPluginType.Android }
});
3D WebView's keyboard prefabs (Keyboard and CanvasKeyboard) use this approach to use the non-Gecko package by default because the keyboard UI uses a transparent background, which Gecko doesn't natively support.