-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This extension allows Android and iOS developers to make use of the WebView to display site URLs directly from inside their game.
The following functions are provided to manipulate the WebView:
Creates a WebView with assigned url.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
WebView_Create(url)
| Argument | Type | Description |
|---|---|---|
| url | String | The URL that the web view will open |
Returns:
N/A
Triggers:
| Key | Type | Description |
|---|---|---|
| type | String | The string "WebView"
|
| event | String | The string "onCloseWindow"
|
Example:
WebView_Create("https://www.yoyogames.com/")The code sample above will create a new webview (with the specified url). This view can be destroyed at any time using the function WebView_Destroy triggering a callback that can be called inside an {event.social}.
if(async_load[?"type"] == "WebView") {
switch(async_load[?"event"])
{
case "onCloseWindow":
show_debug_message("[WebView] This webview is was closed!");
break;
}
}The code above matches the response against the correct event type and logs it to the console.
Destroys a previously created WebView.
Note
If there is no created WebView nothing will happen.
Syntax:
WebView_Destroy()
Returns:
N/A
Example:
WebView_Create();
// Later in the code
WebView_Button_Destroy();
WebView_Destroy();The code above provides a sample of a WebView being created (using WebView_Create, there's a full sample on that function's reference) and later in the code being destroyed.
Attaches a button to the WebView.
Note
If this function is called before the WebView is created, the called is ignored.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
WebView_Button_Add(path)
| Argument | Type | Description |
|---|---|---|
| path | String | The path to the image to be used as button. |
Returns:
N/A
Triggers:
| Key | Type | Description |
|---|---|---|
| type | String | The string "WebView"
|
| event | String | The string "onButtonPressed"
|
Example:
WebView_Create("https://www.yoyogames.com/")
WebView_Button_Add("WebView/img_close.png")The code sample above creates a WebView and attaches a button to it, after this we can catch the click of the button inside an Social Async Event.
if(async_load[?"type"] == "WebView") {
switch(async_load[?"event"])
{
case "onButtonPressed":
WebView_Button_Destroy();
WebView_Destroy();
break;
}
}Destroys the button from the WebView.
Warning
Always make sure to destroy the button before destroying the WebView.
Syntax:
WebView_Button_Destroy()
Returns:
N/A
Example:
WebView_Create();
// Later in the code
WebView_Button_Destroy();
WebView_Destroy();The code above provides a sample of a WebView being created (using {function.WebView_Create}, there's a full sample on that function's reference) and later in the code being destroyed (using the function WebView_Destroy). Note that the button should always be destroyed before the WebView does.
Sets alpha value of the button attached to the WebView. This should be a value ranging from 0 to 1, where 0 means hidden and 1 means fully visible.
Syntax:
WebView_Button_SetAlpha(alpha)
| Argument | Type | Description |
|---|---|---|
| alpha | Real | Value from 0-1. |
Returns:
N/A
Example:
WebView_Create("https://www.yoyogames.com/");
WebView_Button_Add("WebView/img_close.png");
WebView_Button_SetAlpha(0.5);The code above will create a WebView attach it a button and make sure that the button is semi-transparent.
GameMaker 2024