VisionOSWindow

class

Namespace: Vuplex.WebView

Accessible via the VisionOSWebView.Window property, this class provides APIs for manipulating the window of a webview created via VisionOSWebView.CreateInWindow().

Summary

Public properties

Public events

Public properties

IsOpen

bool IsOpen

Indicates whether the window is currently open.

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    var webView = await VisionOSWebView.CreateInWindow();
    if (webView.Window.IsOpen) {
        Debug.Log("Window is open");
    }
#endif

Public methods

Close

void Close()

Closes the window. If the window is already closed, this method has no effect. Note that closing the window doesn't destroy the webview, and the window can be reopened by calling Open(). To destroy the webview, call IWebView.Dispose() instead.

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    webView.Window.Close();
#endif

Open

void Open()

Reopens the window after it has previously been closed with Close(). If the window is already open, this method has no effect. This version of Open() opens the window using the size and position specified when the webview was created with CreateInWindow(). To open the window at a different size and position, use Open(VisionOSWindowOptions).

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    webView.Window.Open();
#endif

Open

void Open(VisionOSWindowOptions options)

Like Open(), except it also accepts a VisionOSWindowOptions parameter for customizing the window's initial size and position.

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    webView.Window.Open(
        new VisionOSWindowOptions {
            Size = new Vector2Int(1000, 1000),
            Position = new VisionOSWindowPosition(
                VisionOSWindowPositionType.Trailing,
                VisionOSWindowPosition.UnityBoundedSceneID
            )
        }
    );
#endif

Important note

The VisionOSWindowsOptions.Size and Position options require visionOS 2.0. On visionOS 1.x, the Size and Position options are ignored, and a window always uses the system's default size and position.

SetFullscreenEnabled

void SetFullscreenEnabled(bool enabled)

Sets whether web pages can use the JavaScript Fullscreen API to make an HTML element occupy the entire webview. The default is true, meaning that the JavaScript Fullscreen API is enabled by default.

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    var webView = await VisionOSWebView.CreateInWindow();
    // Disable the JavaScript Fullscreen API.
    webView.Window.SetFullscreenEnabled(false);
#endif

SetScrollViewBounces

void SetScrollViewBounces(bool bounces)

Sets whether the scroll view bounces past the edge of content and back again. The default is true.

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    var webView = await VisionOSWebView.CreateInWindow();
    webView.Window.SetScrollViewBounces(false);
#endif

Public events

Closed

EventHandler Closed

Indicates that the window closed, either because the user pressed its close button or because the application called Close().

Example

#if UNITY_VISIONOS && !UNITY_EDITOR
    var webView = await VisionOSWebView.CreateInWindow();
    // Add an event handler that destroys the webview when the user closes the window.
    webView.Window.Closed += (sender, eventArgs) => {
        webView.Dispose();
    };
#endif