CanvasKeyboard

class : MonoBehaviour

Like the Keyboard prefab, except optimized for use in a Canvas. You can add a CanvasKeyboard to your scene either by dragging the CanvasKeyboard.prefab file into a Canvas via the editor or by programmatically calling CanvasKeyboard.Instantiate(). For an example, please see 3D WebView's CanvasWorldSpaceDemo scene.

Example

// Create a CanvasKeyboard.
var keyboard = CanvasKeyboard.Instantiate();
keyboard.transform.SetParent(canvas.transform, false);
var rectTransform = keyboard.transform as RectTransform;
rectTransform.anchoredPosition3D = Vector3.zero;
rectTransform.offsetMin = Vector2.zero;
rectTransform.offsetMax = Vector2.zero;
rectTransform.sizeDelta = new Vector2(650, 162);
// Hook up the keyboard so that characters are routed to a CanvasWebViewPrefab in the scene.
keyboard.InputReceived += (sender, eventArgs) => {
    canvasWebViewPrefab.WebView.HandleKeyboardInput(eventArgs.Value);
};

Summary

Public properties

InitialResolution

float InitialResolution

Sets the keyboard's initial resolution in pixels per Unity unit.You can change the resolution to make the keyboard's content appear larger or smaller. For more information on scaling web content, see this support article.

WebViewPrefab

CanvasWebViewPrefab WebViewPrefab

The CanvasWebViewPrefab instance used for the keyboard UI.

Public methods

Instantiate

static Keyboard Instantiate()

Creates a new instance

Public events

Initialized

EventHandler Initialized

Indicates that the keyboard finished initializing.

InputReceived

EventHandler<EventArgs<string>> InputReceived

Indicates that the user clicked a key on the keyboard.