Plug-in to use Android's web browser component (WebView
/ GeckoView
) as uGUI (Texture2D)
- Keyboard Input
- Touch Interaction
- File download (include blob, data url)
- Resize
- Run Javascript
Document is here
Snippets is here
The Java plugin source code is here
- Unity 2021
- Unity 2022
- OpenGLES
- Vulkan
Screenshot run on Android 13, Adreno 619
OS | Android 10 ~ 14 |
GPU | Qualcomm Adreno 505, 619 |
Unity | 2021.3 |
- TLabVKeyborad
v1.0.1+
Please see here
Clone this repository with the following command
git clone https://github.com/TLabAltoh/TLabWebView.git
or
git submodule add https://github.com/TLabAltoh/TLabWebView.git
add package from git URL ...
https://github.com/TLabAltoh/TLabWebView.git#upm
Please see here
- Build Settings
Property | Value |
---|---|
Platform | Android |
- Project Settings
Property | Value |
---|---|
Color Space | Linear |
Minimum API Level | 26 |
Target API Level | 30 (Unity 2021), 31 ~ 32 (Unity 2022) |
- Add the following symbols to Project Settings --> Player --> Other Settings (to be used at build time)
UNITYWEBVIEW_ANDROID_USES_CLEARTEXT_TRAFFIC
UNITYWEBVIEW_ANDROID_ENABLE_CAMERA
UNITYWEBVIEW_ANDROID_ENABLE_MICROPHONE
- Scene
Please add the BrowserManager
to any GameObject (maybe EventSystem is best).
Please create a Plugins folder in your Assets folder and create files in it. And please set the BrowserContainer.browser
to GeckoView
instead of WebView
. Also GeckoView
needs Android 13
~ (API level 33
~). Please set tartget level to API level 33
in the Project Settings
.
- gradleTemplate.properties
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
# android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=**STREAMING_ASSETS**
**ADDITIONAL_PROPERTIES**
android.useAndroidX=true
# android.enableJetifier=true
- mainTemplate.gradle
...
dependencies {
implementation "androidx.annotation:annotation-jvm:1.9.1"
def collection_version = "1.4.3"
implementation "androidx.collection:collection:$collection_version"
def lifecycle_version = "2.6.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
}
...
- GeckoView plugin (
.aar
) (please install the 125.0.20240425211020 version, as this package is only developed and tested with it)
Prefab is here. Just add prefab to the canvas to implement webview
/Resources/TLab/WebView/Browser.prefab
Note
If you want to download the file to external storage (like /Download
, /Picture
), please add the following permission to the manifest. This is required for Android 11+ (see here for more details).
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
Warning
Android WebView doesn't support the WebXR API.
Warning
OculusQuest doesn't support some HTML5 input tags (see below). If you want to use them, please use GeckoView
as Browser
instead of WebView
. It will display a widget implemented by uGUI. Below is the status of HTML5 input tag support by this plugin's custom widget.
Warning
This plugin supports both Vulkan
and OpenGLES
, but if you are building an application that uses a Vulkan
graphics API, the Android device must support OpenGLES (3.1+)
as well as Vulkan
.