You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: microsoft-edge/webview2/get-started/get-started.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@ ms.date: 02/22/2023
10
10
---
11
11
# Getting Started tutorials
12
12
13
-
These articles cover how to set up your development tools and create an initial WebView2 app, like a Hello World app with basic functionality. Learn about WebView2 concepts along the way.
13
+
These articles cover how to set up your development tools and create an initial WebView2 app, like a Hello World app with basic functionality. You learn WebView2 concepts along the way. If you want to run a sample first, see [Win32 sample app](../samples/webview2apissample.md) or another sample app article.
Copy file name to clipboardExpand all lines: microsoft-edge/webview2/get-started/hololens2.md
+2-189Lines changed: 2 additions & 189 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ ms.date: 11/25/2024
12
12
13
13
This tutorial is for developers using WebView2 in immersive HoloLens 2 Unity applications.
14
14
15
+
This article is to learn to write your own WebView2 code. If you want to run a sample first, see [Win32 sample app](../samples/webview2apissample.md) or another sample app article.
16
+
15
17
> [!IMPORTANT]
16
18
> WebView2 on Hololens 2 continues to be available. However, support for WebView2 on Hololens 2 is discontinued; there are no planned bug fixes or content updates, and technical support has ended. Applications that use WebView2 on Hololens 2 are not guaranteed to continue to work.
17
19
@@ -409,195 +411,6 @@ public class WebViewExample : MonoBehaviour, IWithPostMessage
## Additional considerations for WebView2 on HoloLens 2
414
-
415
-
416
-
<!-- ------------------------------ -->
417
-
#### Limitations and known issues
418
-
419
-
When developing a HoloLens 2 Unity app with WebView2, be aware of some limitations and known issues:
420
-
421
-
***Pop-ups**: Pop-ups don't work well within WebView2 inside Unity apps on HoloLens 2, but they work fine in 2D XAML apps on the device. Avoid pop-ups and use alternative techniques or UI designs, such as custom pop-up-like elements within the WebView using HTML, CSS, and JavaScript.
422
-
423
-
***New windows**: WebView2 instances on HoloLens 2 navigate within the same window by default, unlike on Desktop. Follow this default behavior for a better user experience. Additionally, the DevTools window cannot be launched.
424
-
425
-
***Enterprise authentication**: Automatic Single Sign-On (SSO) leveraging OS-level tokens is currently not supported in WebView2 on HoloLens 2. Users can still sign in by providing credentials, except for cases requiring device-level authentication. Cookie storage works as expected.
426
-
427
-
***User interactions**: Unlike native HoloLens 2 slates, WebView2 is best interacted with by using far-interaction hand rays. Touch-to-swipe and scroll interactions might not be supported.
428
-
429
-
***Performance**: Complex websites with heavy use of JavaScript or advanced rendering may impact system performance or the host application's framerate. For general performance-related limitations and recommendations, see [Understanding performance for mixed reality](/windows/mixed-reality/develop/advanced-concepts/understanding-performance-for-mixed-reality) in the mixed reality documentation. Also see [Performance optimization](#performance-optimization), below.
430
-
431
-
432
-
<!-- ------------------------------ -->
433
-
#### Performance optimization
434
-
435
-
Optimizing the performance of WebView2 in your HoloLens 2 Unity app is crucial for a smooth user experience. Here are some recommendations:
436
-
437
-
***Limit the number of WebView2 instances**: We suggest using only one instance of WebView2 within a Unity app. Reuse the same instance or tear down and create a new one as needed. Keep in mind that removing the WebView prefab from the scene might not destroy the underlying WebView2 instance. You must call the `Destroy()` method on the game object to destroy it properly.
438
-
439
-
***Apply general Unity optimization techniques**: To optimize WebView2 performance, use the standard Unity optimization approaches, such as occlusion culling or limiting the update rate. For more information, see [Performance recommendations for Unity](/windows/mixed-reality/develop/unity/performance-recommendations-for-unity?tabs=openxr) in the mixed reality documentation.
440
-
441
-
***Profile and monitor WebView2 performance**: There are several ways to profile the performance of a HoloLens 2 Unity application:
442
-
443
-
***Unity Profiler**: A built-in tool in Unity that allows you to measure and optimize the performance of your application on various platforms, including HoloLens 2.
444
-
445
-
***Visual Profiler**: A feature of the Mixed Reality Toolkit that provides an in-application view of your application's performance.
446
-
447
-
***PIX**: A performance tuning and debugging tool for Windows that can also be used to profile Unity applications on HoloLens 2.
448
-
449
-
450
-
<!-- ------------------------------ -->
451
-
#### Navigation
452
-
453
-
In [Step 7 - Extending WebView2 functionality](#step-7---extending-webview2-functionality), we touched on some navigation methods. In this section, we'll expand on what we learned.
454
-
455
-
See also:
456
-
*[WebView2 API Reference](../webview2-api-reference.md)
457
-
*[API Reference for Mixed Reality WebView plugin](/windows/mixed-reality/develop/advanced-concepts/webview2-unity-plugin) - for HoloLens 2 in the WebView2 Unity plugin.
458
-
<!-- dest. TOC title:
459
-
WebView2 Unity Plugin API -->
460
-
461
-
462
-
<!-- ---------- -->
463
-
###### IWebView interface
464
-
465
-
<!-- [IWebView::Load method]()-->
466
-
467
-
The `IWebView` interface exposes a few methods, events, and properties related to page navigation. The main functionality exposed here is the ability to navigate to a given URL, by using `Load(Uri url)`:
468
-
469
-
```C#
470
-
publicinterfaceIWebView
471
-
{
472
-
// Non-navigation methods are removed for clarity.
473
-
474
-
eventWebView_OnNavigatedNavigated;
475
-
476
-
UriPage { get; }
477
-
478
-
voidLoad(Uriurl);
479
-
480
-
voidReload(boolignoreCache);
481
-
}
482
-
```
483
-
484
-
485
-
<!-- ---------- -->
486
-
###### IWithBrowserHistory interface
487
-
488
-
The `IWithBrowserHistory` interface exposes a few methods and events related to page navigation. This mainly allows developers to navigate forward and backward, as you would expect with a typical web-browsing experience:
489
-
490
-
```C#
491
-
publicinterfaceIWithBrowserHistory : IWebView
492
-
{
493
-
// Non-navigation methods are removed for clarity.
###### SetVirtualHostNameToFolderMapping and SetVirtualHostMapping
508
-
509
-
The [CoreWebView2.SetVirtualHostNameToFolderMapping Method](/dotnet/api/microsoft.web.webview2.core.corewebview2.setvirtualhostnametofoldermapping) enables mapping between a virtual host name and a folder path, making it accessible to websites using that host name. This method maps a local domain name to a local folder, so that the WebView2 control loads content from the specified local folder when attempting to access a resource for that domain.
510
-
511
-
The WebView plugin for Unity exposes this functionality through the `IWithVirtualHost` interface, which has a single method, `SetVirtualHostMapping(string hostName, string folderPath)`:
To use the `SetVirtualHostMapping` method, set `hostName` to any valid URL conforming string, such as `webview2.sample`. `folderPath` can be an absolute path or a path relative to the application's working directory, such as `Assets\Html`.
521
-
522
-
Assuming we have an HTML file called `demo.html` under `Assets\Html`, the following code snippet demonstrates loading `demo.html` by using the WebView plugin for Unity:
Regardless of the input system used within your Unity application, interop code between the various application input events and the WebView plugin for Unity is required. This means translating those events (such as Pointer events) into a `WebViewMouseEventData` object and then forwarding those events to the plugin via the `IWithMouseEvent` interface:
WebView2 is unaware of Unity's input system and likely has a different coordinate system than your Unity scene. As a result, when there is a pointer-down event, its coordinates must be translated into the coordinate system of the WebView2 control. Additionally, the pointer-down event needs to be converted into an appropriate `WebViewMouseEventData` event type.
In the above example, pointer-down events are converted into `WebViewMouseEventData` objects and forwarded to the WebView plugin for Unity. It is essentially converted into a mouse-down event. In order to create mouse click events, pointer-up events would need to be handled in a similar fashion.
597
-
598
-
In the example above, `ConvertToWebViewSpace` is intentionally not implemented.
Copy file name to clipboardExpand all lines: microsoft-edge/webview2/get-started/win32.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ ms.date: 07/29/2022
12
12
13
13
<!-- TODO: Rewrite to start from a project template? -->
14
14
15
+
This article is to learn to write your own WebView2 code. If you want to run a sample first, see [Win32 sample app](../samples/webview2apissample.md) or another sample app article.
16
+
15
17
In this article, you set up your development tools (if not done already), learn how to add WebView2 code to a Win32 app project, and learn about WebView2 concepts along the way.
16
18
17
19
This tutorial starts by opening an existing Win32 app project that has WebView2 code added. The project uses the [Win32_GettingStarted (WebView2GettingStarted.sln)](https://github.com/MicrosoftEdge/WebView2Samples/tree/main/GettingStartedGuides/Win32_GettingStarted) directory that's part of the `WebView2Samples` repo. To use this article, you do the following:
Copy file name to clipboardExpand all lines: microsoft-edge/webview2/get-started/winforms.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ ms.date: 10/26/2022
10
10
---
11
11
# Get started with WebView2 in WinForms apps
12
12
13
+
This article is to learn to write your own WebView2 code. If you want to run a sample first, see [Win32 sample app](../samples/webview2apissample.md) or another sample app article, such as [WinForms sample app](../samples/webview2windowsformsbrowser.md).
14
+
13
15
<!--
14
16
todo: errors experienced with vs2022 by following these instructions:
15
17
* The addressbar text box & Go button shift to the right when alt+tab to the Form1 window.
0 commit comments