Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Displaying and interacting with a web page within scene

Discussion in 'AR/VR (XR) Discussion' started by faalbane, Mar 24, 2020.

  1. faalbane


    May 23, 2019
    I'm trying to better understand how to build this functionality from scratch (blank project).

    I'm aware of assets like 3D WebView and ZFBrowser (which are $200 and $80 respectively).

    What does it take to build a bare-bones functional web browser in a scene?
  2. JoeStrout


    Jan 14, 2011
    Well, in broad terms, you would need an HTML parser (and probably a CSS parser too), and a layout engine that can create, arrange, and style all the different spans of text and images and tables and so on as Unity UI objects.
  3. a436t4ataf


    May 19, 2013
    ...and for 20-30% of websites: a javascript engine, because (Sadly) a lot of web-devs make the page layout in javascript (jquery: I'm glaring at you :)).

    HOWEVER ... if you control the webpage you're loading, and you only want simple HTML/CSS then it gets much easier. I wrote my own CSS/Flexbox layout engine within UnityUI (there's a free version on the AssetStore with the main features), and you can plug together a few things like that to get your own simple HTML/CSS rendering. Off the top of my head ... there are open-source HTML/DOM parsers that will give you the HTML as C# objects in memory, then you'd need to feed those into an open-source layout-engine (personally I'd only use Flexbox - if you control the webpage, there's no reason to use anything else, flex is the modern CSS layout and it works much better than the old CSS1/CSS2 ones). If you know what you're doing, and find the right combination of third party (free) tools and open-source projects, you could probably get something working in day or so.

    On the other hand ... if you want to be able to open Gmail ... you'll need a few years of your time just to get it all working.

    TL;DR: how many years do you have to devote to this "render a webpage" project? :)
    JoeStrout likes this.