Search Unity

Browsing the web within Unity Editor

Discussion in 'Made With Unity' started by VoxelBoy, Nov 14, 2010.

  1. VoxelBoy

    VoxelBoy

    Joined:
    Nov 7, 2008
    Posts:
    240
    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.

    $unityWebBrowser.jpg

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

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Hey, men. How can I reproduce it?
     
  3. killerz

    killerz

    Joined:
    Aug 28, 2010
    Posts:
    32
    Wow very nice!
     
  4. VoxelBoy

    VoxelBoy

    Joined:
    Nov 7, 2008
    Posts:
    240
    Here's the source of the current version. It's still got some ways to go but it's a start.
    View attachment $WebWindow.cs

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

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Thank you !
     
  6. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    Wow.
    Is it possible to use Webkit in runtime?
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No the webkit API is only in the editor and there likely just for Unity Asset Store :)

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

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Very interesting!

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

    VoxelBoy

    Joined:
    Nov 7, 2008
    Posts:
    240
    Yes, you can point it to an HTML file on your computer and it will render it just like any other WebKit-powered browser.
     
  10. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Awesome, this could be very useful!

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

    Thanks
     
  11. atsanna

    atsanna

    Joined:
    Jun 6, 2013
    Posts:
    3
    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.
     
  12. Hannibalov

    Hannibalov

    Joined:
    Aug 8, 2012
    Posts:
    6
    I get the same error.

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

    Thanks
     
  13. TheGamedevGuru

    TheGamedevGuru

    Joined:
    Jun 3, 2015
    Posts:
    10
  14. NathanHale1776

    NathanHale1776

    Joined:
    Mar 22, 2014
    Posts:
    46
    Is there a way to make this NOT editor window but a window in game/app?
     
  15. rraallvv

    rraallvv

    Joined:
    Jul 30, 2013
    Posts:
    16
    @RubenTorres 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.
     
  16. rraallvv

    rraallvv

    Joined:
    Jul 30, 2013
    Posts:
    16
    @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.
     
  17. VoxelBoy

    VoxelBoy

    Joined:
    Nov 7, 2008
    Posts:
    240
    @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.
     
  18. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    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.
     
  19. VoxelBoy

    VoxelBoy

    Joined:
    Nov 7, 2008
    Posts:
    240
    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.
     
  20. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    @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
     
  21. trackaroo

    trackaroo

    Joined:
    Nov 14, 2014
    Posts:
    1
    Unity crashes when closing Unity with the WebEditorWindow open (on Mac, Unity 5.5). Any ideas? It's occurring during the destroy phase.

    3 com.unity3d.UnityEditor5.x 0x0000000101f9702d ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 125
    14 com.unity3d.UnityEditor5.x 0x0000000101f96f2b ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*) + 59
    15 com.unity3d.UnityEditor5.x 0x000000010249f3e1 MonoBehaviour::CallMethodInactive(ScriptingMethodPtr) + 353
    16 com.unity3d.UnityEditor5.x 0x0000000101bf9135 DestroyObjectHighLevel(Object*, bool) + 837
    17 com.unity3d.UnityEditor5.x 0x000000010247f4a9 DestroyWorldObjects(dynamic_array<int, 4ul> const&) + 697
    18 com.unity3d.UnityEditor5.x 0x000000010247f15d DestroyWorld(bool) + 93
    19 com.unity3d.UnityEditor5.x 0x000000010281b218 Application::CoreShutdown() + 88
    20 com.unity3d.UnityEditor5.x 0x00000001028201ce Application::Terminate() + 686
     
  22. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
  23. rambutan2000

    rambutan2000

    Joined:
    Feb 7, 2018
    Posts:
    1
    Anyone know if you can modify the HTTP header on GET requests in the editor webview?
     
  24. Hemanth_DJ

    Hemanth_DJ

    Joined:
    Aug 12, 2017
    Posts:
    13
    t
    Hi thanks for the link this works in editor tabs, I need to implement the same in the canvas UI or texture Please help
     
  25. Fortitude3D

    Fortitude3D

    Joined:
    Sep 7, 2017
    Posts:
    155
    Nice add-on, thankyou :)
     
  26. z3nth10n

    z3nth10n

    Joined:
    Nov 23, 2013
    Posts:
    55
    To achieve this you could use this snippet: https://wiki.unity3d.com/index.php/HtmlTexturePlugin

    Hope it helps!
     
  27. unity_3F03B4CB4DCE7F7CCC42

    unity_3F03B4CB4DCE7F7CCC42

    Joined:
    Sep 5, 2021
    Posts:
    3
    Does this not work anymore since they removed asset store browsing in Unity 2020 and above?
     
    lclemens likes this.
  28. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    Excellent question. I suspect so.

    According to https://github.com/willnode/WebViewHook , the current situation is: "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."