Browsing the web within Unity Editor

Hey folks,

As of Unity 3.1, it is now possible to browse the web from within the Editor.
Thanks to WebKit being bundled with the Editor application and the new WebView private API.

You might ask:
Is it really that hard to Cmd-Tab to your browser? No, not really. Still though, I cherish the thought of never having to leave the cozy confines of the Unity Editor :slight_smile: This could also prove useful for in-Editor Unity Doc search. I intend to extend PixelPlacement’s Doc Search (with his permission) and add the documentation webpage directly to the Editor.

Hey, men. How can I reproduce it?

Wow very nice!

Here’s the source of the current version. It’s still got some ways to go but it’s a start.
430449–14935–$WebWindow.cs (3.62 KB)

You might get a few Null Ref exceptions but they’re harmless. Reflection seems to delay returning a method that’s called in OnGUI.

Thank you !

Wow.
Is it possible to use Webkit in runtime?

No the webkit API is only in the editor and there likely just for Unity Asset Store :slight_smile:

Also going by U3s track of privating stuff etc, its possible that the access to it through private editor api is gone again soon

Very interesting!

Is it possible to show offline pages? For example, help pages?

Yes, you can point it to an HTML file on your computer and it will render it just like any other WebKit-powered browser.

Awesome, this could be very useful!

I am surprised that such a powerful feature is not part of the public API.

Thanks

I tried but does not work with Unity 4.
This is the error:

Instance of WebView could not be created Because there is no script With That name.
NullReferenceException: Object reference not set to an instance of an object
WebWindow.InitWebView () (at Assets / Risviel / Editor / WebWindow.cs: 47)
WebWindow.Init () (at Assets / Risviel / Editor / WebWindow.cs: 40)
WebWindow.Load () (at Assets / Risviel / Editor / WebWindow.cs: 31)

Can you help me, please?
Thank you.

I get the same error.

Did you work out a solution? This would be very useful for me.

Thanks

Update: https://gist.github.com/cofruben/26882cf1a800c93eb24c7cbe15cbb7fa

1 Like

Is there a way to make this NOT editor window but a window in game/app?

@TheGamedevGuru_1 I tried your gist, the web view is showing ok but it gets hidden after the window is docked. Do you know how to get it to show again? maybe by repainting or resizing the web view. Thanks for sharing.

@VoxelBoy do you know if there could be communication in both directions WindowEditor ↔ WebView. i.e. invoking methods in the window editor from a script running in the web view and vice versa.

@rraallvv It might be possible but I haven’t looked into it, to be honest. With a .NET decompiler, you can take a look at what the AssetStore-xxxx classes are doing and maybe figure something out from there.

Is the type “WebView” only available at Unity Editor runtime ? I cant find it in UnityEditor.dll or am i on the wrong track? "WebView is found by Reflection like in the script from Ruben Torres , but even the Visual Studio (2017) Object Browser dosent show it.
Anyone knows in wich .dll/Assembly it originally really is or where it is loaded from and then injected into UnityEditor.dll?

Thanks.
Karsten.

I can see it in UnityEditor.dll when I look at it with DotPeek. I checked it in Unity 5.5 and 5.4. It should be there for you too.

@VoxelBoy , yes i also used DotPeek now, anyway its interesting that VS cant see it, looks like the ObjectBrowser from VS 2017 could use someone taking more care about it, some objects you see some you dont even if they have similiar scopes, smells buggy.
However, looking into UnityEditor.Web triggers me see the abstract-> UnityEditor.Web.WebViewEditorWindow and its implementations