UniWebViewEmbeddedToolbarConfig

Summary

Represents the configuration for the embedded toolbar.

A config object describes the full toolbar layout: which items appear (back, forward, done, reload, title, or custom buttons), how they are arranged (left, center, right sections), their colors, and title interaction behaviors.

Use UniWebViewEmbeddedToolbarConfig.Default for the standard layout (back + forward on the left, title in the center, done on the right), or construct your own config. Apply the config by calling UniWebViewEmbeddedToolbar.ApplyConfig.

Properties Summary

The current config version.

The prefix used for all built-in item identifiers (`"uwv.

Identifier for the back navigation button (`"uwv.

Identifier for the forward navigation button (`"uwv.

Identifier for the done (close) button (`"uwv.

Identifier for the reload button (`"uwv.

Identifier for the title item (`"uwv.

A built-in item with predefined behavior (back, forward, done, reload, title).

A custom button defined by the user.

Back navigation button.

Forward navigation button.

Done (close) button.

Reload button.

Title label displayed in the center section.

Gets the default toolbar config.

Gets the JSON string representation of the default config.

The config version.

Whether the toolbar is visible.

The position of the toolbar.

The maximum height of the toolbar in points.

The background color of the toolbar.

The default text color for toolbar buttons (back, forward, done, reload, custom).

The text color for the title item.

The list of items to display on the left section of the toolbar.

The list of items to display in the center section of the toolbar.

The list of items to display on the right section of the toolbar.

Red component, in the range [0, 1].

Green component, in the range [0, 1].

Blue component, in the range [0, 1].

Alpha component, in the range [0, 1].

The text color of this item.

No action on tap.

Scroll the web view content to the top of the page.

No action on long press.

Copy the current page URL to the system clipboard and show a toast.

The action to perform when the title is tapped.

The action to perform when the title is long-pressed.

The toast message text shown after copying the URL.

The type of this item (built-in or custom).

A unique identifier for this item.

Optional per-item visual style.

The kind of built-in item.

The display text for this item.

Whether this item is visible.

Interaction config for the built-in Title item.

Methods Summary

Creates a config from a JSON string.

Serializes the config to a JSON string.

Converts the config to a dictionary representation that can be serialized to JSON.

Enumerates all items across all sections (left, center, right) in order.

Finds the first built-in item matching the given kind across all sections (left, center, right).

Creates a ColorValue from a Unity Color.

Converts this ColorValue to a Unity Color.

Creates a built-in toolbar item.

Creates a custom toolbar button.

Returns whether this item is visible.

Properties

The current config version. Currently 1.

The prefix used for all built-in item identifiers ("uwv.toolbar.").

Identifier for the back navigation button ("uwv.toolbar.back").

Identifier for the forward navigation button ("uwv.toolbar.forward").

Identifier for the done (close) button ("uwv.toolbar.done").

Identifier for the reload button ("uwv.toolbar.reload").

Identifier for the title item ("uwv.toolbar.title").

A built-in item with predefined behavior (back, forward, done, reload, title).

Gets the default toolbar config.

The default config contains: back and forward buttons on the left, a title item in the center, and a done button on the right. Position is Top, visibility is true, and colors use platform defaults.

Gets the JSON string representation of the default config.

The config version. Currently always 1.

Whether the toolbar is visible. Default is true.

The position of the toolbar. Either Top or Bottom. Default is Top.

This property only takes effect on iOS and Android. On macOS Unity Editor, the toolbar is always in the window's title bar.

The maximum height of the toolbar in points. If set to a value smaller than the standard height, the toolbar will shrink to that height.

This property only takes effect on iOS and Android.

The background color of the toolbar. When null, the platform default is used.

The default text color for toolbar buttons (back, forward, done, reload, custom). When null, the platform default is used. Individual items can override this via Item.Style.TextColor.

The text color for the title item. When null, the platform default is used. The title item can override this via its own Item.Style.TextColor.

The list of items to display on the left section of the toolbar.

In the default config, this contains the back and forward built-in items.

The list of items to display in the center section of the toolbar.

In the default config, this contains the title built-in item. You can also add other built-in or custom buttons to the center section alongside the title.

The list of items to display on the right section of the toolbar.

In the default config, this contains the done built-in item.

Red component, in the range [0, 1].

Green component, in the range [0, 1].

Blue component, in the range [0, 1].

Alpha component, in the range [0, 1].

The text color of this item. When set, overrides the global ButtonTextColor or TitleTextColor.

The action to perform when the title is tapped. Default is None.

The toast message text shown after copying the URL. If not set, "URL copied" is used. Only applicable when OnLongPress is CopyUrl.

The type of this item (built-in or custom).

A unique identifier for this item. Built-in items use uwv.toolbar.* identifiers by default. Custom items must provide their own identifier.

Optional per-item visual style. When set, overrides global color settings.

The kind of built-in item. Only applicable when Type is BuiltIn.

The display text for this item. For built-in items, if not set, a platform default is used. For custom items, this is the button label.

Whether this item is visible. If null or true, the item is shown. Set to false to hide it.

Interaction config for the built-in Title item. Only applicable when Kind is Title.

Methods

Creates a config from a JSON string. Returns null if the JSON is invalid or empty.

Parameters
  • string json

    A JSON string representing the toolbar config.

Serializes the config to a JSON string.

Converts the config to a dictionary representation that can be serialized to JSON.

Enumerates all items across all sections (left, center, right) in order.

Finds the first built-in item matching the given kind across all sections (left, center, right).

Returns null if no matching item is found.

Parameters
  • UniWebViewEmbeddedToolbarConfig.BuiltInItemKind kind

    The built-in item kind to search for.

Example

var config = UniWebViewEmbeddedToolbarConfig.Default;
var titleItem = config.FindFirstBuiltInItem(
    UniWebViewEmbeddedToolbarConfig.BuiltInItemKind.Title
);
titleItem.Title = "My App";

Creates a ColorValue from a Unity Color.

Parameters
  • Color color

    The Unity color to convert.

Example

var color = UniWebViewEmbeddedToolbarConfig.ColorValue.FromColor(Color.red);

Converts this ColorValue to a Unity Color.

Creates a built-in toolbar item.

Built-in items are: Back, Forward, Done, Reload, and Title. Each has a default text and identifier. You can override the title, visibility, style, and (for the Title item) title interaction.

Parameters
  • UniWebViewEmbeddedToolbarConfig.BuiltInItemKind kind

    The kind of built-in item to create.

  • string title

    Optional title text override. If null, the platform default text is used.

  • bool? visible

    Optional visibility override. If null, the item is visible by default.

  • UniWebViewEmbeddedToolbarConfig.ItemStyle style

    Optional style override for this item.

  • UniWebViewEmbeddedToolbarConfig.TitleInteraction titleInteraction

    Optional title interaction config. Only applicable to the Title built-in item.

  • string identifier

    Optional identifier override. By default, built-in items use uwv.toolbar.* identifiers.

Example

// Create a reload button.
var reload = UniWebViewEmbeddedToolbarConfig.Item.BuiltIn(
    UniWebViewEmbeddedToolbarConfig.BuiltInItemKind.Reload
);

// Create a title with scroll-to-top interaction.
var title = UniWebViewEmbeddedToolbarConfig.Item.BuiltIn(
    UniWebViewEmbeddedToolbarConfig.BuiltInItemKind.Title,
    title: "My App",
    titleInteraction: new UniWebViewEmbeddedToolbarConfig.TitleInteraction {
        OnTap = UniWebViewEmbeddedToolbarConfig.TitleInteraction.TapAction.ScrollToTop
    }
);

Creates a custom toolbar button.

Custom items require an identifier and a title. When tapped, the item's action is delivered through RegisterOnEmbeddedToolbarItemAction on the UniWebView instance. Custom items have no native default action.

Parameters
  • string identifier

    A unique identifier for the custom item. Used to identify the item in action callbacks.

  • string title

    The button title text.

  • UniWebViewEmbeddedToolbarConfig.ItemStyle style

    Optional style for this item.

Example

var shareButton = UniWebViewEmbeddedToolbarConfig.Item.Custom(
    "my.share",
    "Share"
);

Returns whether this item is visible. An item is visible when Visible is null or true.