Apr 09 2024 02:26 AM
Hello,
I'm currently working on a mixed reality project in Unity for the hololens 2, where I need to implement WebView functionality. I downloaded the webview (preview) component via the mixed reality tool. In this project I am mainly trying to add vocal commands that will interact directly with the webview component (scroll up and down). For that i first followed the instructions on the microsoft documentation on how to add vocal command in unity for hololens 2 apps https://learn.microsoft.com/en-us/training/modules/use-eye-tracking-voice-commands/6-5-exercise-voic....
Then the last step was to write and add the script that would handle the scrolling. Within the script I use the namespace "using Microsoft.MixedReality.WebView;" do not seems to handle javascript commands therefore i get this error ( error CS1061: 'WebView' does not contain a definition for 'ExecuteScriptAsync' and no accessible extension method 'ExecuteScriptAsync' accepting a first argument of type 'WebView' could be found (are you missing a using directive or an assembly reference?)).
To address this issue I browsed microsoft documentation and found out that "using Microsoft.Web.WebView2.Core". Adding this namespace seems to resolve the javascript issue, however this gives me another issue (error CS0234: The type or namespace name 'Web' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?))
I've tried to manually add the Microsoft.Web.WebView2 package through the NuGet Package Manager in Visual Studio, but the package doesn't appear to be recognized in Unity, nor does it appear in my packages-lock.json file. I understand that Unity does not natively support NuGet packages, and WebView2 is a .NET package typically used in .NET projects, not Unity projects.
I've also tried to find a WebView2 wrapper or plugin for Unity, and I found a reference to a "Mixed Reality WebView plugin (Preview) https://learn.microsoft.com/en-us/windows/mixed-reality/develop/advanced-concepts/webview2-unity-plu..." on Microsoft's website, but the link provided leads I could not do much with. I couldn't find any other resources, documentation, or download links for this plugin.
I would appreciate any assistance or guidance on how to correctly implement WebView2 in my mixed reality Unity project. Specifically, I'm looking for information on how to add the Microsoft.Web.WebView2 package to a Unity project, or how to use the Mixed Reality WebView plugin (if available).
Thank you for your time and assistance.
Here is the script: