Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Displaying and interacting with a web page within scene

Discussion in 'VR' started by faalbane, Mar 24, 2020.

  1. faalbane

    faalbane

    Joined:
    May 23, 2019
    Posts:
    3
    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?
     
    Fairyessfeli likes this.
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    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

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    ...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.
  4. Fairyessfeli

    Fairyessfeli

    Joined:
    Aug 30, 2020
    Posts:
    6
    But with a custom owned site the web view could be accomplished in a day or two... is creating the website the only real issue aside from programming the app?! I'm trying to do what they're doing but we only need it to reach out to our pay site if necessary.
     
  5. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    If you fully control the website then why would you need to leave the app? (You wouldn't).

    If you're using a 3rd party payment provider, that doesn't have an integration with Unity (and so: forces you to create a webpage) ... then: you need to support every piece of JS/HTML/CSS that the payment-provider uses. Typically they have quite a lot of javascript in their embedded code - so you'll need a full javascript-execution-engine.