Search Unity

WebGL on Blazor app not working?

Discussion in 'Web' started by stevencr4z, Oct 10, 2020.

  1. stevencr4z

    stevencr4z

    Joined:
    Jul 2, 2020
    Posts:
    5
    So I'm trying to add a Unity WebGL build to a Blazor page, but I'm not sure how. I made a cshtml file and put the normal Unity-built HTML code in there. I put the other two build files in /Data.


    2020-10-09.png

    When I access the page from my browser, however, it doesn't work as the regular HTML file does. What am I doing wrong?
     
    MartinHelvig likes this.
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    When something is not working, posting the web console error logs, and any errors (HTTP 404) seen in the Network transfers tab to the forum thread are the two first things to do, otherwise people attempting to help will likely be stabbing in the dark with unhelpful suggestions.

    Also, if you are able to host a reduced failing test case somewhere live, and/or zip up the broken build and attach it to the forum post, that can also help others to suggest what might be going wrong.
     
  3. stevencr4z

    stevencr4z

    Joined:
    Jul 2, 2020
    Posts:
    5
    I don't think there's any other information I could provide. All I did was copy and paste the index.html from the build to a .cshtml in my Blazor app, and then added the @Page "/game" on top so I could access the page. I figured there must be something huge I'm missing here as I don't understand much about web development and don't know where to start to figure out how to make this simple thing work.
     
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    The template starts with
    <!DOCTYPE html>
    and
    <html lang="en-us">
    , ends with
    </html>
    - and it looks like your HTML starts with
    <head>
    , maybe try again without skipping that stuff? I've never personally heard of Blazor, so maybe you're not actually supposed to include it.. but given you said all you did was copy/paste, that's what stood out.
     
  5. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    You can look for errors in the web browser console, and on the Network tab. See e.g.

    https://developers.google.com/web/tools/chrome-devtools/open
    https://developers.google.com/web/tools/chrome-devtools/console
    https://developer.mozilla.org/en-US/docs/Tools/Browser_Console
    https://wordpress.org/support/artic...nsole will open,errors try reloading the page.

    Those can help you get started on how to look at errors when they come up.
     
    De-Panther and adamgolden like this.