This Unity project demonstrates how to view and interact with web content on Apple Vision Pro using Vuplex 3D WebView with Unity's Metal app mode for visionOS. All you need to do is import 3D WebView for visionOS. The VisionOSMetalWebViewExample.cs script demonstrates how to use 3D WebView's scripting APIs, and you can also toggle the script's PassthroughEnabled field to toggle passthrough (enabled by default).
Notes:
-
3D WebView's native visionOS plugin can't run in the editor, so a mock webview implementation is used by default while running in the editor unless 3D WebView for Windows and macOS is also installed.
-
There is not currently an example of interacting with the non-Canvas WebViewPrefab on visionOS.
- Downloaded v2.0.4 of Unity's visionOS template project and opened it with Unity 6 (6000.0.25).
- Opened the Unity Package Manager window, navigated to the page for the installed com.unity.xr.visionos package, clicked on the package's "Samples" tab, and then clicked the "Import" button for "Metal Sample - URP".
- Made a copy of the visionOS Metal sample scene named VisionOSMetalWebViewExample:
mkdir Assets/Scenes
cp "Assets/Samples/Apple visionOS XR Plugin/2.0.4/Metal Sample - URP/Scenes/Main.unity" Assets/Scenes/VisionOSMetalWebViewExample.unity
-
Made the following modifications to the copied VisionOSMetalWebViewExample.unity scene:
- Copied and pasted the Canvas object from 3D WebView's CanvasWorldSpaceDemo scene in to the scene.
- Deleted the scene's original "Sample Canvas" canvas and repositioned the Canvas from the CanvasWorldSpaceDemo scene to take its place.
- Made the following changes to the Canvas object:
- Set its Event Camera to the scene's main camera
- Added a Tracked Device Graphic Raycaster component
- Removed the CanvasKeyboard child object
- Deleted unneeded extra objects from the scene.
- Removed AR-related scripts from objects (e.g. AR Plane Manager).
- Added a "Scripting API Example" object with a VisionOSMetalWebViewExample.cs script that demonstrates how to use 3D WebView's scripting APIs and toggle the passthrough.
-
Deleted unneeded subdirectories from the Assets folder, such as the Assets/Samples directory containing the original sample scenes.