Scripting API
This section introduces functions for operating TLabWebView.
Initialize
Init
Parameters
Name | Type | Description |
---|---|---|
webWidth | int | WebView Width |
webHeight | int | WebView Height |
texWidth | int | Texture2D Width |
texHeight | int | Texture2D Height |
url | string | URL that loads first |
dlOption | DownloadOption | The directory of the device to which the content is being downloaded. |
subDir | string | Subdirectory of the directory from which the content is downloaded. |
IsInitialized
If it returns true
, this WebView component is already initialized.
Type | Description |
---|---|
bool | whether or not this WebView component is initialized. |
Update Frame
GetTexturePtr
Return the Texture Pointer of the WebView frame.
Type | Description |
---|---|
IntPtr | texture pointer of the webview frame |
UpdateFrame
Request Webview to update frame.
Capture HTML Element
CaptureHTMLSource
Gaptures HTML currently displayed async.
CaptureElementById
Gapture specific HTML elements currently displayed async.
Parameters
Name | Type | Description |
---|---|---|
id | string | target html element tag |
CurrentHTMLCaptured
Gets the HTML value currently captured.
Type | Description |
---|---|
string | HTML value currently captured. |
Load URL
LoadUrl
Loads the given URL.
Parameters
Name | Type | Description |
---|---|---|
url | string | the URL of the resource to load. |
LoadHTML
Loads the given HTML.
return
Name | Type | Description |
---|---|---|
html | string | the html of the resource to load. |
baseURL | string | baseURL |
GoForward
Goes forward in the history of this WebView.
GoBack
Goes back in the history of this WebView.
Zoom In/Out
ZoomIn
Performs zoom in in this WebView.
ZoomOut
Performs zoom out in this WebView.
Scroll
GetScrollX
Get content's scroll position x
return
Type | Description |
---|---|
int | Page content's current scroll position x |
GetScrollY
Get content's scroll position y
return
Type | Description |
---|---|
int | Page content's current scroll position y |
ScrollTo
Set content's scroll position
Parameters
Name | Type | Description |
---|---|---|
x | int | Scroll position x of the destination |
y | int | Scroll position y of the destination |
ScrollBy
Move the scrolled position of webview
Parameters
Name | Type | Description |
---|---|---|
x | int | The amount of pixels to scroll by horizontally |
y | int | The amount of pixels to scroll by vertically |
PageUp
Scrolls the contents of this WebView up by half the view size.
Parameters
Name | Type | Description |
---|---|---|
top | bool |
|
PageDown
Scrolls the contents of this WebView down by half the page size.
Parameters
Name | Type | Description |
---|---|---|
bottom | bool |
|
User Agent
CaptureUserAgent
Capture current userAgent async.
GetUserAgent
Gets the currently captured userAgent string.
return
Type | Description |
---|---|
string | userAnget String that is currently being captured. |
SetUserAgent
Update userAgent with the given userAgent string.
Parameters
Name | Type | Description |
---|---|---|
ua | string | userAgent string |
reload | bool | If true, reload web page when userAgent is updated. |
Javascript
EvaluateJS
Run Javascript on the current web page.
Parameters
Name | Type | Description |
---|---|---|
js | string | javascript |
send a message from javascript to unity.
SetOnPageFinish
Register Javascript to run when the page is finished loading.
Parameters
Name | Type | Description |
---|---|---|
onPageFinish | string | javascript |
SetOnDownloadStart
Register Javascript to run when download event starts.
Parameters
Name | Type | Description |
---|---|---|
onDownloadFinish | string | javascript |
SetOnDownloadFinish
Register Javascript to run when download event finishes.
Parameters
Name | Type | Description |
---|---|---|
onDownloadStart | string | javascript |
Download Event
SetDlEventVariableName
Defines the download event parameter's name. it can be accessed from javascript when a download event occurs.
Parameters
Name | Type | Description |
---|---|---|
dl_url_name | string | URL of the file to be downloaded |
dl_uri_name | string | The destination for the downloaded file. |
dl_id_name | string | The ID of the download event. |
SetDlOption
Set the directory in which the file will be downloaded.
Parameters
Name | Type | Description |
---|---|---|
option | DownloadOption | Download location for the files. |
DownloadOption
Name | Description |
---|---|
applicationFolder | Application's external files directory. |
downloadFolder | Standard directory in which to place files that have been downloaded by the user. |
SetSubDir
Specifies the subdirectory from which the files are to be downloaded.
Parameters
Name | Type | Description |
---|---|---|
subdir | string | The subdirectory from which the files are downloaded. This directory is created under the directory specified in DownloadOption. |
RequestCaptureDownloadProgress
Asynchronous capture of download event progress.
GetDownloadProgress
Get the progress of the download event currently being recorded.
Interaction
TouchEvent
Dispatch of a touch event
Parameters
Name | Type | Description |
---|---|---|
x | int | Touch position x |
y | int | Touch position y |
eventNum | int | Touch event type (TOUCH_DOWN: 0, TOUCH_UP: 1, TOUCH_MOVE: 2) |
KeyEvent
Dispatch of a basic keycode event
Name | Type | Description |
---|---|---|
key | char | 'a', 'b', 'A' .... |
BackSapce
Dispatch of a backspace key event
Clear Cache
ClearCache
Clear WebView Cache.
Name | Type | Description |
---|---|---|
includeDiskFiles | bool | If false, only the RAM cache will be cleared. |
ClearCookie
Clear WebView Cookie.
ClearHistory
Clear WebView History
Resize
ResizeTex
Update WebView Texture Resolusion
Parameters
Name | Type | Description |
---|---|---|
texWidth | int | Texture new width |
texHeight | int | Texture new height |
ResizeWeb
Update WebView Resolution
Parameters
Name | Type | Description |
---|---|---|
webWidth | int | WebView new width |
webHeight | int | WebView new height |
Resize
Update Resolusion for both WebView and Texture
Parameters
Name | Type | Description |
---|---|---|
texWidth | int | Texture new width |
texHeight | int | Texture new height |
webWidth | int | WebView new width |
webHeight | int | WebView new height |
Last updated