C# Class UWKWebView, html-ui-unity

WebView component used to render and interact with web content
Inheritance: MonoBehaviour
ファイルを表示 Open project: ufz-vislab/html-ui-unity Class Usage Examples

Public Properties

Property Type Description
ContentSizeChanged ContentSizeChangedDelegate
CurrentHeight int
CurrentWidth int
JSConsole JSConsoleDelegate
JSMessageReceived JSMessageReceivedDelegate
LoadFinished LoadFinishedDelegate
LoadProgress LoadProgressDelegate
MaxHeight int
MaxWidth int
NewViewRequested RequestNewViewDelegate
ScrollSensitivity float
TitleChanged TitleChangedDelegate
URL string
URLChanged URLChangedDelegate

Public Methods

Method Description
AddToGameObject ( GameObject gameObject, string url = "", int maxWidth = 1024, int maxHeight = 1024 ) : UWKWebView,

Dynamically adds a UWKWebView component to a GameObject with initialization that isn't possible using GameObject.AddComponent due to lack of constructor parameters

Awake ( ) : void

Initializes the UWKWebView, registers default delagates, and creates textures for the page and icon to lack of constructor parameters

Back ( ) : void

Moves back in the page history

ClearCookies ( ) : void

Clears all user cookies

CloseInspector ( ) : void

Closes the Web Inspector window Associated with this View

DisableInput ( ) : void

Globally enables mouse and keyboard input from webviews

DrawTextIME ( int x, int y ) : void

Draws the text IME for Chinese, Japanese, Korean languages

DrawTexture ( Rect position, bool alphaBlend = true ) : void
EnableInput ( ) : void

Globally disabled mouse and keyboard input from webviews

EvaluateJavascript ( string javascript, JSEvalDelegate callback = null ) : void

Evaluates Javascript on the page Example with return value: EvaluateJavascript("document.title", (value) => { Debug.Log(value); });

Forward ( ) : void

Moves forward in the page history

GetApplicationDataURL ( ) : string
Hide ( ) : void

Hide the page, the page will no longer be rendered by the web rendering process saving CPU time

IMEFocusIn ( UWKMessage, &msg ) : void

Page is focusing a text entry area in IME mode

IMEFocusOut ( ) : void

Page is removing focus for text area in IME mode

IconChanged ( int width, int height, byte bytes ) : void

Sets the icon texture to the given width/height and image bytes

LoadHTML ( string HTML, string baseURL = "" ) : void

Loads the specified HTML string directly in the view, can be used for generating web content on the fly

LoadURL ( string url ) : void

Navigate the view to the specified URL (http://, file://, etc)

Navigate ( Navigation, n ) : void

Navigates forward or back in the page history

OnDestroy ( ) : void
ProcessKeyboard ( Event keyEvent ) : void

Process a Unity keyboard event

ProcessMouse ( Vector3 mousePos ) : void

Process the mouse given mousePos coordinates

Reload ( ) : void

Reloads the current page contents

SendJSMessage ( string msgName ) : void

Sends a Javascript message to the page

SendJSMessage ( string msgName, object>.Dictionary msgValues ) : void

Sends a Javascript message to the page

SendJSMessage ( string msgName, object value ) : void

Sends a Javascript message to the page

SendJSMessage ( string msgName, string key, object value ) : void

Sends a Javascript message to the page

SetAlphaMask ( bool enabled ) : void

Enabled or disables alpha mask rendering of view

SetCurrentSize ( int width, int height ) : void

Sets the current width and height of the UWKWebView

SetFrameRate ( int framerate ) : void

Sets the framerate that the view is rendered at in the web rendering process Default is 30fps, to set 60fps you would call view.SetFrameRate(60); Please note that higher fps settings will increase CPU load

SetScrollPosition ( int x, int y ) : void

Sets the page's sceoll positon

SetTextCaretColor ( uint color ) : void

Sets the color of the text input caret in the form of 0xAARRGGBB Default is opaque black 0xFF000000

SetUserAgent ( string agent = "" ) : void

Sets the user agent the browser reports, setting the agent to "" will use the default uWebKit agent

SetZoomFactor ( float zoom ) : void

Sets the zoom factor of the page

Show ( ) : void

Makes the page visible, the page will be updated and refreshed by the Wweb rendering process

ShowInspector ( ) : void

Opens a platform Web Inspector Window

Start ( ) : void
Stop ( ) : void

Stops the current page load

Update ( ) : void
Visible ( ) : bool

Gets whether the page is visible or not

contentSizeChanged ( UWKWebView, view, int width, int height ) : void
jsConsole ( UWKWebView, view, string message, int line, string source ) : void
jsMessageReceived ( UWKWebView, view, string message, string json, object>.Dictionary values ) : void
loadFinished ( UWKWebView, view ) : void
loadProgress ( UWKWebView, view, int progress ) : void
newViewRequested ( UWKWebView, view, string url ) : void
titleChanged ( UWKWebView, view, string title ) : void
urlChanged ( UWKWebView, view, string url ) : void

Method Details

AddToGameObject() public static method

Dynamically adds a UWKWebView component to a GameObject with initialization that isn't possible using GameObject.AddComponent due to lack of constructor parameters
public static AddToGameObject ( GameObject gameObject, string url = "", int maxWidth = 1024, int maxHeight = 1024 ) : UWKWebView,
gameObject GameObject
url string
maxWidth int
maxHeight int
return UWKWebView,

Awake() public method

Initializes the UWKWebView, registers default delagates, and creates textures for the page and icon to lack of constructor parameters
public Awake ( ) : void
return void

Back() public method

Moves back in the page history
public Back ( ) : void
return void

ClearCookies() public static method

Clears all user cookies
public static ClearCookies ( ) : void
return void

CloseInspector() public method

Closes the Web Inspector window Associated with this View
public CloseInspector ( ) : void
return void

DisableInput() public static method

Globally enables mouse and keyboard input from webviews
public static DisableInput ( ) : void
return void

DrawTextIME() public method

Draws the text IME for Chinese, Japanese, Korean languages
public DrawTextIME ( int x, int y ) : void
x int
y int
return void

DrawTexture() public method

public DrawTexture ( Rect position, bool alphaBlend = true ) : void
position Rect
alphaBlend bool
return void

EnableInput() public static method

Globally disabled mouse and keyboard input from webviews
public static EnableInput ( ) : void
return void

EvaluateJavascript() public method

Evaluates Javascript on the page Example with return value: EvaluateJavascript("document.title", (value) => { Debug.Log(value); });
public EvaluateJavascript ( string javascript, JSEvalDelegate callback = null ) : void
javascript string
callback JSEvalDelegate
return void

Forward() public method

Moves forward in the page history
public Forward ( ) : void
return void

GetApplicationDataURL() public static method

public static GetApplicationDataURL ( ) : string
return string

Hide() public method

Hide the page, the page will no longer be rendered by the web rendering process saving CPU time
public Hide ( ) : void
return void

IMEFocusIn() public method

Page is focusing a text entry area in IME mode
public IMEFocusIn ( UWKMessage, &msg ) : void
msg UWKMessage,
return void

IMEFocusOut() public method

Page is removing focus for text area in IME mode
public IMEFocusOut ( ) : void
return void

IconChanged() public method

Sets the icon texture to the given width/height and image bytes
public IconChanged ( int width, int height, byte bytes ) : void
width int
height int
bytes byte
return void

LoadHTML() public method

Loads the specified HTML string directly in the view, can be used for generating web content on the fly
public LoadHTML ( string HTML, string baseURL = "" ) : void
HTML string
baseURL string
return void

LoadURL() public method

Navigate the view to the specified URL (http://, file://, etc)
public LoadURL ( string url ) : void
url string
return void

Navigate() public method

Navigates forward or back in the page history
public Navigate ( Navigation, n ) : void
n Navigation,
return void

OnDestroy() public method

public OnDestroy ( ) : void
return void

ProcessKeyboard() public method

Process a Unity keyboard event
public ProcessKeyboard ( Event keyEvent ) : void
keyEvent Event
return void

ProcessMouse() public method

Process the mouse given mousePos coordinates
public ProcessMouse ( Vector3 mousePos ) : void
mousePos Vector3
return void

Reload() public method

Reloads the current page contents
public Reload ( ) : void
return void

SendJSMessage() public method

Sends a Javascript message to the page
public SendJSMessage ( string msgName ) : void
msgName string
return void

SendJSMessage() public method

Sends a Javascript message to the page
public SendJSMessage ( string msgName, object>.Dictionary msgValues ) : void
msgName string
msgValues object>.Dictionary
return void

SendJSMessage() public method

Sends a Javascript message to the page
public SendJSMessage ( string msgName, object value ) : void
msgName string
value object
return void

SendJSMessage() public method

Sends a Javascript message to the page
public SendJSMessage ( string msgName, string key, object value ) : void
msgName string
key string
value object
return void

SetAlphaMask() public method

Enabled or disables alpha mask rendering of view
public SetAlphaMask ( bool enabled ) : void
enabled bool
return void

SetCurrentSize() public method

Sets the current width and height of the UWKWebView
public SetCurrentSize ( int width, int height ) : void
width int
height int
return void

SetFrameRate() public method

Sets the framerate that the view is rendered at in the web rendering process Default is 30fps, to set 60fps you would call view.SetFrameRate(60); Please note that higher fps settings will increase CPU load
public SetFrameRate ( int framerate ) : void
framerate int
return void

SetScrollPosition() public method

Sets the page's sceoll positon
public SetScrollPosition ( int x, int y ) : void
x int
y int
return void

SetTextCaretColor() public method

Sets the color of the text input caret in the form of 0xAARRGGBB Default is opaque black 0xFF000000
public SetTextCaretColor ( uint color ) : void
color uint
return void

SetUserAgent() public method

Sets the user agent the browser reports, setting the agent to "" will use the default uWebKit agent
public SetUserAgent ( string agent = "" ) : void
agent string
return void

SetZoomFactor() public method

Sets the zoom factor of the page
public SetZoomFactor ( float zoom ) : void
zoom float
return void

Show() public method

Makes the page visible, the page will be updated and refreshed by the Wweb rendering process
public Show ( ) : void
return void

ShowInspector() public method

Opens a platform Web Inspector Window
public ShowInspector ( ) : void
return void

Start() public method

public Start ( ) : void
return void

Stop() public method

Stops the current page load
public Stop ( ) : void
return void

Update() public method

public Update ( ) : void
return void

Visible() public method

Gets whether the page is visible or not
public Visible ( ) : bool
return bool

contentSizeChanged() public method

public contentSizeChanged ( UWKWebView, view, int width, int height ) : void
view UWKWebView,
width int
height int
return void

jsConsole() public method

public jsConsole ( UWKWebView, view, string message, int line, string source ) : void
view UWKWebView,
message string
line int
source string
return void

jsMessageReceived() public method

public jsMessageReceived ( UWKWebView, view, string message, string json, object>.Dictionary values ) : void
view UWKWebView,
message string
json string
values object>.Dictionary
return void

loadFinished() public method

public loadFinished ( UWKWebView, view ) : void
view UWKWebView,
return void

loadProgress() public method

public loadProgress ( UWKWebView, view, int progress ) : void
view UWKWebView,
progress int
return void

newViewRequested() public method

public newViewRequested ( UWKWebView, view, string url ) : void
view UWKWebView,
url string
return void

titleChanged() public method

public titleChanged ( UWKWebView, view, string title ) : void
view UWKWebView,
title string
return void

urlChanged() public method

public urlChanged ( UWKWebView, view, string url ) : void
view UWKWebView,
url string
return void

Property Details

ContentSizeChanged public_oe property

Delegate fired when the content size of the page has changed
public ContentSizeChangedDelegate ContentSizeChanged
return ContentSizeChangedDelegate

CurrentHeight public_oe property

Gets the current height of the UWKWebView
public int CurrentHeight
return int

CurrentWidth public_oe property

Gets the current width of the UWKWebView
public int CurrentWidth
return int

JSConsole public_oe property

Delegate fired when the page has output something to console.log
public JSConsoleDelegate JSConsole
return JSConsoleDelegate

JSMessageReceived public_oe property

Delegate fired when the page has received a Javascript message
public JSMessageReceivedDelegate JSMessageReceived
return JSMessageReceivedDelegate

LoadFinished public_oe property

Delegate fired when the page has finished loaded
public LoadFinishedDelegate LoadFinished
return LoadFinishedDelegate

LoadProgress public_oe property

Delegate fired when the page has updated the loading progress 0-100
public LoadProgressDelegate LoadProgress
return LoadProgressDelegate

MaxHeight public_oe property

Max height of the UWKWebView, defined at creation time. It is possible to set the view's current height to be equal or smaller than this value
public int MaxHeight
return int

MaxWidth public_oe property

Max width of the UWKWebView, defined at creation time. It is possible to set the view's current width to be equal or smaller than this value
public int MaxWidth
return int

NewViewRequested public_oe property

Delegate fired when the page has requested a popup window be created
public RequestNewViewDelegate NewViewRequested
return RequestNewViewDelegate

ScrollSensitivity public_oe property

Used to make the scroll wheel/trackpad more sensitive
public float ScrollSensitivity
return float

TitleChanged public_oe property

Delegate fired when the Title of the page has changed
public TitleChangedDelegate TitleChanged
return TitleChangedDelegate

URL public_oe property

The initial URL to load
public string URL
return string

URLChanged public_oe property

Delegate fired when the URL of the page has changed
public URLChangedDelegate URLChanged
return URLChangedDelegate