Unity

After an instant or a tournament game is published, it can be integrated into a mobile application or game built with Unity.

Overview

The WindayWrapper class provides functionality to display and interact with web content within a Unity application using a WebView.

It allows for loading web pages, handling events, and communicating with web content through JavaScript.

Setup

  1. Install the plugin and toggle the dropdown menu Internet Access: Required in Project settings.

Constructor

WindayWrapper()

Description: Initializes the WebView and sets up event handlers.

Example:

WindayWrapper webView = new WindayWrapper();

Methods

1. Subscribe(string eventName, Action callback)

Description: Subscribes to an event that does not pass any data. The callback will be executed when the event is triggered.

Parameters:

  • eventName: The name of the event to listen to.

  • callback: The action to execute when the event is triggered.

Example:

2. Subscribe<T>(string eventName, Action<T> callback) where T : class

Description: Subscribes to an event that passes data. The callback will receive data associated with the event.

Parameters:

  • eventName: The name of the event.

  • callback: The action to execute when the event is triggered, receiving data of type T.

Example:

3. Unsubscribe(string eventName)

Description: Unsubscribes from a previously subscribed event, removing all callbacks associated with the event.

Parameters:

  • eventName: The name of the event to unsubscribe from.

Example:

4. SetVisible(bool visible)

Description: Sets the visibility of the WebView. When visible, the WebView is rendered and interactive.

Parameters:

  • visible: true to make the WebView visible, false to hide it.

Example:

5. LoadPage(string url)

Description: Loads a web page in the WebView using the specified URL.

Parameters:

  • url: The URL of the web page to load.

Example:

6. SetMargins(int left, int top, int right, int bottom, bool relative = false)

Description: Sets the margins of the WebView, defining how it is positioned on the screen.

Parameters:

  • left: Left margin in pixels.

  • top: Top margin in pixels.

  • right: Right margin in pixels.

  • bottom: Bottom margin in pixels.

  • relative: If true, the margins are defined as a percentage of the screen size; otherwise, they are in pixels.

Example:

7. OnPageStartLoading

Description: This event is triggered when a new web page begins loading in the WebView. It provides the URL of the page that is starting to load.

Example:

8. OnPageLoaded

Description: This event is triggered when the web page has finished loading successfully. It also provides the URL of the loaded page.

Example:

9. OnClosed

Description: This event is triggered when the WebView is destroyed or closed. It signals that the WebView is no longer active and has been removed from the scene.

Example:

Event Examples

exit-mobile-plugin

Description: Triggered when the user wants to exit the mobile plugin.

Example:

winday-game-win

Description: Triggered when the user wins the game.

Example:

winday-game-lose

Description: Triggered when the user loses the game.

Example:

winday-game-tutorial-start

Description: Triggered when the tutorial starts.

Example:

winday-game-tutorial-complete

Description: Triggered when the tutorial is completed.

Example:

winday-game-colors

Description: Triggered when game color data is sent.

Example:

Last updated