Posted on

Web View – Cross Platform Native Plugins: Essential Kit

Download

Documentation: https://assetstore.essentialkit.voxelbusters.com/

0:00 Welcome to Web View Cross Platform Native Plugins: Essential Kit
0:23 Overview
1:20 Setup
1:57 Usage

The Web View service makes it so you can display a web page through a window in your game. This can be used in several different ways such as having a web login screen or display your terms and conditions.

IG_Webview.cs

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VoxelBusters.CoreLibrary;
using VoxelBusters.EssentialKit;

public class IG_Webview : MonoBehaviour
{
    public static IG_Webview instance;

    WebView CurrentWebView;

    private void OnEnable()
    {
        // register for events
        WebView.OnShow += OnWebViewShow;
        WebView.OnHide += OnWebViewHide; 
        WebView.OnLoadStart += OnWebViewLoadStart; 
        WebView.OnLoadFinish += OnWebViewLoadFinish; 
    }

    

    private void OnDisable()
    {
        // register for events
        WebView.OnShow -= OnWebViewShow;
        WebView.OnHide -= OnWebViewHide; 
        WebView.OnLoadStart -= OnWebViewLoadStart; 
        WebView.OnLoadFinish -= OnWebViewLoadFinish; 
    }
    // Start is called before the first frame update
    void Start()
    {
        instance = this;
    }

    //IG_Webview.instance.NewWebView(webpageURL);
    public void NewWebView(string URL)
    {
        CurrentWebView = WebView.CreateInstance();
        CurrentWebView.SetFullScreen();
        CurrentWebView.LoadURL(URLString.URLWithPath(URL));
        CurrentWebView.Show();
    }

    //IG_Webview.instance.HideCurrentWebview();
    public void HideCurrentWebview()
    {
        CurrentWebView.Hide();
    }


    private void OnWebViewShow(WebView result)
    {
        Debug.Log("Webview is being displayed : " + result);
    }

    private void OnWebViewHide(WebView result)
    {
        Debug.Log("Webview is hidden : " + result);
        
    }

    private void OnWebViewLoadStart(WebView result)
    {
        Debug.Log("Webview is being displayed : " + result);
    }

    private void OnWebViewLoadFinish(WebView result, Error error)
    {
        Debug.Log("Webview is being displayed : " + result);
    }

    
}