• This repository has been archived on 02/Dec/2021
  • Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Exposed Unity Editor WebView API

WebViewHook

Warning: WebViewHook is obsolete for Unity 2020 and Above due to removal of Asset Store Browsing in Unity Editor. This project is soon to be archived.

This is a code snippet to access a hidden WebView API from Unity Editor, and load it to EditorWindow.

Screenshot

Code

Download WebViewHook. See usage example in WebWindow or WebEditor. You may download the whole project if necessary.

Usage

Minimum code to get WebView working:

class WebViewDemo : EditorWindow
{

    WebViewHook webView;

    void OnEnable()
    {
        if (!webView)
        {
            // create webView
            webView = CreateInstance<WebViewHook>();
        }
    }

    public void OnBecameInvisible()
    {
        if (webView)
        {
            // signal the browser to unhook
            webView.Detach();
        }
    }

    void OnDestroy()
    {
        //Destroy web view
        DestroyImmediate(webView);
    }

    void OnGUI()
    {
        // hook to this window
        if (webView.Hook(this))
            // do the first thing to do
            webView.LoadURL("https://google.com");

        if (ev.type == EventType.Repaint)
        {
            // keep the browser aware with resize
            webView.OnGUI(new Rect(Vector2.zero, this.position.size));
        }
    }
}

Two Way Communication

Using LoadURL, LoadHTML and ExecuteJavascript you only can send information to WebView.

To extract informations from WebView you need external communication, and the easiest way to do this is by using Web Socket.

To get web socket server running you need to download WebSocket-Sharp and a script utility from this repo.

See WebData for minimal working example of using WebSocketHook to hook C# into javascript variable.

More Information and Caveats

This is an editor only solution. If you're looking to add WebView to a game build then this is not the repo you're looking for.

The technology behind WebView is Chrome Embedded Framework, version 37. In Windows it's contained inside the gigantic libcef.dll.

WebView in Unity is just like Chrome, with background-color default to darkgrey and no plugins (Flash/Java/PDF) allowed.

I solving bugs as I can, but of course limited. If you can't open a specific website, mostly comes down to the fact that Unity haven't upgrade their CEF browser.

More Repositories

1

MeshDebugger

🌐 First-class Mesh debugging tools for Unity
C#
115
star
2

forward-domain

Forward Domains, completely free and open source.
JavaScript
114
star
3

deobfuscator

Online Javascript Deobfuscator Tool
JavaScript
110
star
4

autobloom

Make Windows 11 Bloom Wallpaper Animated when signing in.
Batchfile
68
star
5

N-Matrix-Programmer

A software to write an optimized code that calculates inverse and determinant of N by N matrix.
C#
41
star
6

Vs2017-LayoutInGUI

Generate CL Argument for Offline Visual Studio 2017 Installation.
C#
26
star
7

Qu3e-Sharp

Lightweight and Simple 3D Open Source Physics Engine ported to C#
C#
25
star
8

secure-localhost

Proxy your specified localhost port to HTTPS, with automatic certificate installation.
JavaScript
19
star
9

Iconizer

Image to Icon Converter with High Quality Output
C#
8
star
10

cms-toolkit-with-coreui

CMS Tookit with CoreUI
PHP
8
star
11

ci4-admin-lte

CodeIgniter4 with Admin LTE 3 Template
PHP
8
star
12

crm-toolkit

Battery-Included CodeIgniter, React, Material-UI Template
PHP
7
star
13

frontgen

Clean Website Builder using CSS Frameworks (WIP)
JavaScript
6
star
14

forger

Website Builder based on Svelte
Svelte
5
star
15

Usink

⚑ Supercharge Unity Editor with hotkeys and functionalities
C#
4
star
16

random-youtube

Watch some random YouTube video!
HTML
3
star
17

Ascii-Painter

.NET Based Text painting tool
C#
3
star
18

IsoCreatorLib

Create ISO Files in .NET (Fork Repository)
C#
3
star
19

Nottorus-Unofficial-Patches

Nottorus Visual Scripting Unofficial Patches
3
star
20

screend

Screen Daemon
Go
3
star
21

udp-hole-lab

JavaScript
2
star
22

Socket-Clipboard

LAN-wide clipboard syncronization tool using .NET TCP socket
C#
2
star
23

engine4-doc

Documentation for Engine4
HTML
2
star
24

forwarddomain.net

forwarddomain.net website 🏑
JavaScript
2
star
25

uas-gitlab-auth

πŸ”‘ Microservice to grant access to GitLab private repo using Asset Store Invoice API.
JavaScript
2
star
26

bandit

πŸ±β€πŸ‘€ The swiss army of hacking tools
JavaScript
1
star
27

url-deconstruct

Extract some information behind URL parameters
JavaScript
1
star
28

PD

Jupyter Notebook
1
star
29

test-gatsby-hmr-bug

JavaScript
1
star
30

yourlifeindots

Your life in a page of black dots (inspired by WBW)
HTML
1
star
31

artiscii

Artistic text creation made fun 😎
JavaScript
1
star
32

bandit-proxy

πŸ”« A dangerous proxy for unrestricted XHR access in browser
JavaScript
1
star
33

willnode.github.io

List of repositories I made
1
star
34

sdit-raport

PHP
1
star
35

uas-public-stat

Custom public statistics for packages in Unity Asset Store
HTML
1
star
36

trunojoyo-assets

JavaScript
1
star
37

strapi-db-query-demo

Demonstrating database transactions in Strapi ✨
JavaScript
1
star
38

Nafza-Faroidh

Aplikasi Desktop untuk Penghitungan Faroidh atau Waris mewaris harta peninggalan menurut Ajaran Islam
C#
1
star
39

Network-Facts

Common C# Network Snippets (with a working WPF Demo)
C#
1
star