Integrating GeckoView into Unity - xrchisense/xrevent-broadcaster-unity GitHub Wiki

GeckoView is a broser engine API for Android. Essentially Gekkoview is Gecko packaged as reuseable Android library. It is used to power Firefox on Android devices starting from version xxx. Due to its decoupled nature from the GUI it is also used in other browsers especially built for VR such as Firefox Reality (Github Repo). It serves a similar purpose to the Android build-in WebView (based on Chromium), but is in contrast to that including advanced Web functionalities.

Diagram of the technology stack for the GeckoDemo

Prerequisites

  • Unity 2020.3.22f1
  • We will be using Ian Philips implementation of the GeckoView to build on for our integration. Download the code as Zip file as we will be using some parts of it later.
  • OVROverlay distributed now in the 'Oculus Integration' Package available fom the Unity Store. The relevant folder to import is the VR folder, which includes the OVROverlay.

Installing required Unity Assets

  1. Use the URP Unity Template to start off with a new Unity project. Delete the 'Example Assets' and 'Post-Processing Volume' from the 'Hierarchy'. Delete the 'Tutorial Info' and 'ExampleAssets' folder in the Project View from the 'Asset' Folder. This should give us a cleaner start off.
  2. Install the 'XR Plugin Management' from the File > Build Settings ... > 'Player Settings ...'.
  3. After Installation switch to the 'Android Settings' tab and check 'Oculus' for Oculus support. Close window.
  4. Install OVROverlay. To do so, download the 'Oculus Integration' version 44.0 from the Unity Store. The best way to do this is to download the Unity package to you Hard Drive and execute it from there.
  5. The OVROverlay library is located in the 'Oculus/VR' folder. So only import the 'VR' folder from the 'Oculus Integration Package to your project.
  6. The Importer will prompt you for 'Update of the Utilities Plugin' to Version 1.7.6.0. Click 'Yes'.
  7. The Importer will prompt you for 'OpenXR Backend'. Click 'Use OpenXR'. You can also 'Cancel'. It is not needed.
  8. 'Restart' Unity.

Configuring Unity and Installing GeckoView Implementation

  1. Switch to Android Platform in the 'Build Settings'.
  2. In 'Player Settings' > 'Player' > 'Other Settings' select minimum 'API Level' of 25 or larger. Switch 'Scripting Backend' to 'IL2CPP'.
  3. Copy the contents from the .zip (without .meta files) of 'UnityProject/Assets/Plugin/Android' over to your 'Assets/Plugin/Android' folder.
  4. Copy 'BrowserView.cs' and 'UnityThreads.cs' from the 'Assets/Scripts' folder to your 'Assets/Scripts' folder.
  5. Copy the 'NotScripts' folder to your Asset folder.
  6. Copy 'OverlayBrowserDemo.unity' from the 'Scenes' folder to your 'Scenes' folder.
  7. Open the Scene in Unity.
  8. You will be asked to install Text Mesh Pro (TMP). Only import the 'TMP Essentials' and close window.
  9. In the Hierarchy viewer select 'OVRCameraRig' and search the 'OVR Manager' component (script) for 'Requires System Keyboard' which is listet under the heading 'Quest Features'. Check this, as it will enable the OVR API to use the standard virtual keyboard, which is required to enter an URL to the address bar of the browser.
  10. ISSUE: There is an issue with the 'OVRGazePointer' in the Hierarchy. Disable it in the Inspector. This will make the selection process in the app somewhat difficult, but the browser itself should work. This needs a FIX!
  11. Some links are broken in the 'OverlayBrowserView' entity. Add the missing Script 'BrowserView.cs' from the Scripts folder and add the missing entities. 'GoBack', 'GoForward', 'TextMeshPro - InputField', 'Progress Text', 'OVRGazePointer', 'WebViewClickPanel'. You can use the search function to find them. They are all in the 'WebviewPanel' entity.
  12. (Hint!) The browser only works for Android. It will NOT work in the Editor. So, connect your Quest 2 and 'Build and Run'
  13. 'Add open Scenes' to the Build and remove the 'SampleScene'. Select your Oculus 2 device and 'Build and Run'.

Debugging Android specific code

  • The fastest way for Android debugging of Unity applications, is to use the Android Development Bridge (adb). It is already installed when Unity Android support is instaled. Typical pathes are: 'C:\Program Files\Unity\Hub\Editor\2020.3.22f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools'
  • To connect to the Oculus 2 via USB-C just type adb start -a Unity. This will give you the debug output.