WebGL on Blazor app not working?

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.

When I access the page from my browser, however, it doesn’t work as the regular HTML file does. What am I doing wrong?

1 Like

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.

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 @ “/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.

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.

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/article/using-your-browser-to-diagnose-javascript-errors/#:~:text=Press%20Command%2BOption%2BJ%20(,menu%2C%20and%20click%20Console%20tab.&text=The%20error%20console%20will%20open,errors%20try%20reloading%20the%20page.

Those can help you get started on how to look at errors when they come up.

2 Likes