Winday - Help Center
HomepageLogin Brand Panel
English
English
  • What is Winday
  • Getting Started
  • Create Campaigns
    • Instant Game
      • Discount Codes
    • Tournament Game
      • Booster Codes
    • Supervised Setup
  • Publish Campaigns
    • Game link
    • QR Code
    • Connect to custom domain (Change CNAME)
    • Publish on Website
      • Manual Installation
      • Shopify
      • WordPress
      • Joomla
    • Publish in Mobile App
      • WebView
      • Unity
    • Publish in Telegram Bot
    • Winday Club Visibility
    • Winday Club Brand Page
  • Analytics
    • Built-in Analytics
    • Google Analytics
  • Winday Account
    • User Account
    • Brand Settings
      • Brand Verification
    • Pricing
  • API
    • Booster Codes API
  • FAQ & Tutorials
    • FAQ
    • Video Tutorials
  • Releases
    • May 2025 - New Payment Plans, Advanced SEO, Better Performance
    • Dec 2024 - Brand Landing Page, Localization, Partner Program, and Much More
    • Aug 2024 - New Features, New Publishing Options
  • Legal
    • Legal Pages
Powered by GitBook
On this page
  • Overview
  • Setup
  • Constructor
  • Methods
  • Event Examples

Was this helpful?

  1. Publish Campaigns
  2. Publish in Mobile App

Unity

PreviousWebViewNextPublish in Telegram Bot

Last updated 2 months ago

Was this helpful?

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. Download the .

  2. 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:

webView.Subscribe("exit-mobile-plugin", () => { Debug.Log("Exiting the mobile plugin."); });

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:

webView.Subscribe<GameColors>("winday-game-colors", (colors) => { Debug.Log($"Colors received: Yellow - {colors.yellow}, Blue - {colors.blue}, Red - {colors.red}, Green - {colors.green}, Purple - {colors.purple}"); });

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:

webView.Unsubscribe("exit-mobile-plugin");

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:

webView.SetVisible(true);  // Shows the WebView

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:

webView.LoadPage("https://winday.club/games/VMPWRL3Y?isMobile=true");

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:

webView.SetMargins(10, 10, 10, 10);  // Set 10px margins on all sides

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:

// Instantiate the WindayWrapper
WindayWrapper webViewWrapper = new WindayWrapper();

// Subscribe to the OnPageStartLoading event
webViewWrapper.OnPageStartLoading += (url) =>
{
    Debug.Log($"Page is starting to load: {url}");
};

// Load a new page
webViewWrapper.LoadPage("https://example.com");

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:

// Subscribe to the OnPageLoaded event
webViewWrapper.OnPageLoaded += (url) =>
{
    Debug.Log($"Page has finished loading: {url}");
    webViewWrapper.Show();
};

// Load a new page
webViewWrapper.LoadPage("https://example.com");

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:

// Subscribe to the OnClosed event
webViewWrapper.OnСlosed += () =>
{
    Debug.Log("WebView has been closed.");
};

// Destroy the WebView
webViewWrapper.Destroy();

Event Examples

exit-mobile-plugin

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

Example:

webView.Subscribe("exit-mobile-plugin", () => { Debug.Log("Exiting mobile plugin."); });

winday-game-win

Description: Triggered when the user wins the game.

Example:

webView.Subscribe("winday-game-win", () => { Debug.Log("Player has won the game!"); });

winday-game-lose

Description: Triggered when the user loses the game.

Example:

webView.Subscribe("winday-game-lose", () => { Debug.Log("Player has lost the game."); });

winday-game-tutorial-start

Description: Triggered when the tutorial starts.

Example:

webView.Subscribe("winday-game-tutorial-start", () => { Debug.Log("Tutorial has started."); });

winday-game-tutorial-complete

Description: Triggered when the tutorial is completed.

Example:

webView.Subscribe("winday-game-tutorial-complete", () => { Debug.Log("Tutorial is complete."); });

winday-game-colors

Description: Triggered when game color data is sent.

Example:

webView.Subscribe<GameColors>("winday-game-colors", (colors) => { Debug.Log($"Colors: Yellow - {colors.yellow}, Blue - {colors.blue}, Red - {colors.red}, Green - {colors.green}, Purple - {colors.purple}"); });
Unity Plugin