#๐โweb
1 messages ยท Page 4 of 1
with online do you mean on the webapp right? cause I just receive a string and then I elaborate that at runtime on unity
Its now an mp3 I download froma link
For a rythm game I used this
For StreamingAssets
So the trick is in " using (UnityWebRequest www = UnityWebRequest.Get(Application.streamingAssetsPath + "/" + fileLocation))" I guess
but still I can't figure out how integrate this inside the code ๐
Also seems that you are not even doing the conversion from []byte to AudioClip which is the only step I need to complete it
before i actuall try, i wonder. Can you read out and save to external textfiles in webgl
I tried to export my game to html, put it on itch.io, and its giving me this error on the itch page
"Unable to parse Build/Raining Heads.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug."
Switch to gzip in WebGL player settings. Itch.io still doesn't seem to be serving brotli files correctly
what setting to i change to GZip?
oh wait i found it
hello, can anyone help me? I am using unity 2019.4 on ios, but I cannot seem to find the option to add webgl.
Anyone know what is it? I want to set Enable Exeptions to none but I alway have this.
I am using unity 2022.3.1f1
please make a bit smaller screen shot with less information. Most likely something with allocation. Do you have any warning or errors on editor? as it might work on editor even with errors, it wont work on webgl on any error happening. Also would suggest use Developer build with full stack trace logs to get more data about error.
I am optimizing for FBInstant games, so I want the Enable Exeptions to None when the game go production. So seem Unity will strip Exception system when I set it to None, whenever we throw an exception will lead to that error even we catch the exception or not.
Hello,
i've got an WebGL Project, which crashes on iOS/Safari. In the console i got these Errors (WebKit)
In Desktop i get different error, like in the second picture. Does anybody know, what is happening?
Is it possible to debug a webgl build in the unity editor
YES. you need to build developer build, check autoconnect profiler. If it is hosted on local machine thats all, but otherwise you will need to connect via HTTP in order to get data, https will not work.
Well it states to call Eruda.init(). So I would assume you using some kind of asset. If that asset use multithreading, you are out of luck and it wont work on webgl. Also Editor and Webgl scripts order might not be the same, so make sure that Eruda.init is already done before calling that asset. For more precise errors you can build developer build with full stack trace logs on.
did you set it on None to publishing settings and other settings?:
for the fs.sync, please follow Keli from this discussion: https://forum.unity.com/threads/warning-x-fs-syncfs-operations-in-flight-at-once-probably-just-doing-extra-work.447255/
for other ones, I have no idea.
here is my setting
put everything on none
I think the Mail Problem ist the eruda.init error? It Spams log errors and this causes the Mobile Crash i guess
tku, I am trying.
on webgl almost any error will crash application unless it is in developer mode. So be very carefull wtih red errors.
hmm, it doesn't work. As I said, seem some exception throw somewhere.
if you want to remove all logs you can use java script to remove it at all. but I would not recomend. I would try to find what causes te error instead. so for that would go totally oposite, would put all logs on maximum with full stack trace and would fix it.
when I am testing, the webgl build still got that error even I catch the exeption
this one
so to set the Enable Exeption as none, I assume we have to make sure our projects don't throw any exception, even we catched it.
Fire storage image URL cors error in Unity
Hello. When I make a request to the link of one of the images in my fire storage database, I get a CORS error (e.g.: Access to fetch at 'https://firebasestorage.googleapis.com/v0/b/virtual-museum-3e14f.appspot.com/o/artwork-images%2Fexponat1.jpeg?alt=media&token=060221c5-dd38-44ff-a005-119e9f798125' from origin 'http://localhost:4200/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled).
Accessing the link in the browser works fine, but not in the Unity WebGL app. It all also works properly in the Unity editor. Just not in the Angular UI (where the Unity WebGL app is integrated).
Is there a setting I can make on firebase to disable CORS?
THANKS!!!
Note: I don't use Firebase in Unity or C# at all. I just have the link to some images stored in fire storage, that's it. In Unity I first have the request to the node server, to obtain the url.
Then I have another request to Fire storage for obtaining the image I need.
Hey all. Maybe somebody can help me here. I uploaded a project to itch as a web gl. Sound crackles and then goes silent. Using unity 2020. I've uploaded web gl games with unity 2019 and never had this problem. Is there a known bug? Thanks.
yea, welcome to webgl. Pretty much you can't open files if they are not on the same domain. What you can do is download them via webrequest. There are ways config your server with CORS stuff, but if you will deploy somewhere you dont have access to it, you are in trouble.
Update to 2022LTS. It have way better support for webgl. Also a lot of bug fixes that will not ported back to older versions. I assume there are no errors in browser console? Like FOD errors?
Yeah I updated to the 2022 lts. Thanks for checking in. It appears to be some code in my music player that is conflicting eith web gl. It works fine when I export in other formats. I am going to have to put some more time into it. I managed to get some music to play when I just put it on a game object with an audio source.
How you guys handle videos on iOS webgl? As we all know user needs to interact to play video with sound. Muted one should autoplay without interaction. How you handle that "interaction".
Previously I used pointer down event, as click event on UI does not trigger interaction for some reason. But now I have strange bug that even previous method don't work.
So I was wondering if anyone have better approach or different approach.
Hey everyone, quick question I can't figure out:
When hovering over a button I want the pointer to turn into the hand. I have watched some tutorials and they involve OnMouseEnter/OnMouseOver etc, which is fine but they also upload an asset to act as the finger. Is there a way to just use the default hand and finger?
Thanks
Most brain dead method is using those tutorials and just use default hand and finger images instead of custom. But In general Idk how it will work for you in webgl, unless you Focus window and wont let mouse leave your canvas until you press esc or something then it is fine. but if you want free mouse... you cant do it, as it wont change it look on browser, and in game you will just see two mouses ๐
Thanks! Yea I tried uploading the image of the default hand, but unfortunately when I build into different browsers it isnโt rendering it and it just becomes an invisible pointer which doesnโt work :/
hello guys, does any one knows how can i simulate/Run the OnAudioFilterRead apropriattely on WEB-GL?
What i knoiw is this meythod running on another thread, and it is a pre-process audio phase of Unity....
for some reasons the only way to run my system is by this method; so i want to maybe, wait the pre-process audio phase of page then get from javascript on UnityInstance on all the MonoBehaviours that contains this method then call it...or something like that...
does any one knows how/what can i do it?
i am looking for help on the propper way to do a WebGL build, the people i hired to make a website for me are haveing issues useing my builds
is anyone availiable for a discussion ?
If you followed the guide in documentation that shouldnt be difficult.
https://docs.unity3d.com/Manual/webgl-building.html
The only problem most people meets is that their server is not setuped to support wasm or .br or .gz formats. More about it here:
https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html
what exact problems do you have tho?
Got a niche problem with webGL. A rawimage displaying a camara on a UI canvas disappears when the webGL player goes into full screen, and doesn't come back when you escape back to native size. BUT if you make it full screen while it is loading, it works fine. Other elements on the UI on the same canvas are fine. Just this rawimage.
Oh and it has a shader graph on it
The rawimage that is
Let me turn that off to see if that's the issue
Nope. Using basic URP shaders cause the same issue.
indeed niche problem.
Is that canvas world space or overlay canvas?
Anyways I would try creating a button which turns off and on the canvas. If after that it is visible, that it might be a problem with canvas was not redrawed when scaling up, you can try force canvas redrawing on fullscreen mode.
if it is worldspace then make sure it does not share same plane as oter object, make it just a bit in front of it.
and lastly you can change the draw priority importance of canvas and see if that changes anything
Canvas. Tried "turning it off and on again" with the raw and it didn't work but not the canvas. Gave that a go and not dice. Tried changing priorities but again, the other UI elements are unaffected. It's just this raw image.
Anyone know how to use ForceUpdateCanvases()? Unity docs are trash and VS just throws a "cannot be accessed with an instance reference" at me.
Figured out how ForceUpdate worked but it didn't help
Hello, I'm having a weird bug with the unity version 2022.3.3f1, I'm trying to build the WebGL project and I get this:
Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
Exception in thread Thread-2:
Traceback (most recent call last):
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\threading.py", line 926, in _bootstrap_inner
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\threading.py", line 870, in run
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 1238, in _readerthread
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\cp1252.py", line 23, in decode
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 29: character maps to <undefined>
....
(I can send the full error if you want)
and previously this project was building perfecly fine at version 2021.3.11.f1, does anyone knows what could be causing this?
Does unity support webgl builds for URP Projects?
Thanks
Hello, for some reason my project cannot load past the 90% mark, in a local build. With Build and Run, same in a github page site
Compressions are already completely disabled
I figured it out, you are not supposed to use Web something in WebGL
HI. Anyone familiar with this warning?
WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
the result is a blank page on the browser. I'm not sure if it's related to the memory occupied by the application, because the Unity app doesn't crash (I still see the logs in the console) when there is a blank page.
I have been profiling my webGL build for some time now, and noticed something weird. In some frames (Here highlighted using the red boxes) it spends quite a bit of time in these functions: JS_Sound_SetListenerPosition and JS_Sound_SetListenerOrientation.
I dont need sound in my case, this is completely wasted performance. Is there a way to hard disable this for a build? Or in any other way optimize this out?
What tool is this?
Chrome performance profiler
where can i publish my game its 500mb big i cant do it on itchio 200mb is max someone knows how to share big games?
Not sure if it's ethical to help you drop that WebGL build on the unsuspecting population ๐
Are you using some sort of runtime content delivery setup or do you need to download 500mb just to boot it up?
Use build inspector tools to see what is taking all that space.
Iโm new to unity and Iโm trying to publish a game to itch io, it works fine in unity but when I build it and click start the game doesnโt play. It might be because the game starts at a time scale of 0 and when start is clicked it goes to 1 but idk
Also, how do I make the game format depending on the device?
Check browser's console in case there are messages there.
What do you mean by format?
If I go onto the game with a device with a smaller screen, it cuts off some of the game
You can observe this in the editor by undocking the game view and resizing it around. There are various scaling options for UI, but managing camera size to fit gameplay elements is not built-in.
Alright thanks!
wats that
Tools to parse build logs Unity outputs.
where can i get it
I believe there's one in the package manager and some you can find on github and the asset store.
whats it named
the one in the packet manager
hello! Anybody experiencing issues about shareds using latest unity + webgl + dots ?
Hidden/Universal Render Pipeline/Edge Adaptive Spatial Upsampling shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
Hidden/Universal/HDRDebugView shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
who will bring him bad news?

Whatโs up ๐
https://forum.unity.com/threads/webgl-and-dots.1417806/
you can read it a bit here. But DOTS technicly is not supported on WebGL. You can use some of entities features, but as burst compiler does not work, multithreading dont work and etc, DOTS as fusion of three packages will not work. There were "project tiny" that used dots on webgl, but it got paused (most likely dead and forgotten).
Oh that issue I have with the raw image disappearing when you resize? Only happens on Chrome. Because of course it does. Firefox has no issues.
I have a saving data script that stores the data in a persistent path locally, but it doesn't work on webgl build because im calling that saving data script using OnApplicationQuit method, which doesn't get called when exiting the testing website and re-entering, how can I tell the website to run that script once the player exits or refreshes the website?
hello,
is it possible to include 2 Funktions to an webGL projekt? It should work also an android and iOS?
- Ui Button, on tap a specific telephone number is calles.
- UI Button , on Tap the Data like name, adress and telephone number is saved to contacts
thx ๐
Hello, I'm new to Unity. I bought an asset called Suntail Village, and ran it with webgl just for a test.
And then I recognized that there is a flickering issue, all the grasses and foliage that used the same shader had the problem(although I don't know if this is the main cause of the problem)
I found others who also had flickering issue as well, they said changing the clipping plane range of the camera was the solution, but it did no help for me. Does anyone have any idea how I could fix it?
I would appreciate any answers ๐ ๐
(I'm re-posting this because no one has answered me)
Do you think it could be an animation thing where it is supposed to look like grass blowing in the wind but might be playing it super fast?
I don't think it is, because I tried with the wind blowing animation option turned off, but they still flickered when the camera moved. They are also perfectly fine when it is run in unity engine itself.
I found that they are flickering only when an object is behind it
disable Shadows on your grass
Does anybody has got a hint?
๐
Have never seen WebGL having any of this as in general support for mobiles was made official no so long ago. So I thinkk you will be better with having JavaScript function for it and just call it from webgl. But most likely you will need extra user interaction for it.
I did disable shadows on my grass and it works perfectly fine in unity engine or when I run with Mac.
It can be seen it is the shadow problem but they suddenly become translucent sometimes
I enabled the development console and it says this
actually, the errors in the console was about different thing and I just checked the read/write option of the barrel model and it was fixed
When I checked strict shader variant matching in the player settings, though, the flickering disappeared but these errors of the foliage shader appeared.
Also, these pink planes from the blend model appeared
and they somehow become transparent in the shadows
Hi, I have built and uploaded my webgl game to unity play. But it only loads upto 90 % and stops. Can someone help me to solve this ?
Check the browser's console for hints.
Hi, how can I open my webgl game after I built it. I tried opening the index file but it just gives me error, do I need to deploy it?
Depends how you opened it and what the error is
If you want to open it locally on your own computer then choose Build and Run in Unity
Is build and run the only way to open it locally?
No, but it's by far the easiest
ok
Build and Run spins up a local server to serve it to you. You can do the same with any web server.
Does anyone have a guide for perf and optimization for webgl?
HI GUYS i need help in webXR ,i need to pick an object using handtracking in webvr how to do?
I'm trying to upload a WebGL build, but once I get it to processing it stops working. It will start on 2%, but then revert to 0% and stay there. Is this normal or am I uploading it wrong?
crickets intensify
Nevermind, I resolved it. I mistook the wrong file for the build file.
nvm i think its good
If I set enable exceptions to none, the webgl build pauses on error, is there anyway to make it continue playing?
Please help, when I put webGL onto Unity play, I keep getting an error of a directory not found exception of the folder I literally just put it in and exists
How do I fix this
This hasnโt happened before, I donโt know whatโs wrong
Are you able to use Itch.io instead of Unity Play? Not sure how many people are actively using it to have faced similar issues
Posting complete errors could also be helpful
I am not doing itch because I just basically want to play on Unity play without creating another account or anything like that
And also it just opens my browser and I pretty much click save and itโs done
Worth noting that Build & Run option does something similar, just locally
Oh ok
I fixed this by restarting my pc ๐
The not found folder error
Just restarting Unity didn't fix it?
Does anybody knows how I can communicate from the Unity WebGL app to the react of the website the game is hosted?
I'm struggling to find any useful documentation and some ways that gets suggested on the documentations are obsolete and not supported anymore
So an embedded unity webgl game is a react component, so you would need to pass data to and from that component like you would any other react component
Unity can make calls to unmanaged javascript that can talk on behalf of the component https://github.com/jeffreylanters/react-unity-webgl/blob/main/testing/project/Assets/Plugins/WebGL/Bridge.jslib
Hello there, the other day when I was building my game for the GMTK game jam It wasn't working. Today I decided to try to figure it out and found that using await Task.Delay() causes the build to shit itself and stop working without throwing any errors into the console. Anyone know if this is just something to do with async and WebGL or if there is some setting I'm missing somewhere?
C# Task API relies on multithreading in various places. If you want to continue using Tasks on all platforms, consider something like UniTask.
I read somewhere that I can use simple SendMessage in unity and react can "listen" that context
The sendMessage might be from React to Unity direction https://react-unity-webgl.dev/docs/api/send-message
The send message function lets you asynchronously invoke a method in the Unity game.
This library here is for establishing a websocket in unity for browser communication (what I'm familiar with). The meat and potatoes of it is in the managed to unmanaged calls between js and C# https://github.com/jirihybek/unity-websocket-webgl/tree/master
but you could include something in your app.jsx that talks with your js plugin
so that C# can call that unmanaged js, and then the unmanaged js passes it along to the react component
With the react-unity-webgl library, you can establish bidirectional communication between Unity and React. To call methods from Unity to React, you can follow these steps:
- In your React component, define a method that will be called from Unity:
function myReactMethod(parameter) {
// Perform actions in your React component
console.log("Received data from Unity:", parameter);
// Perform any other actions with the received data
}
- In your Unity project, use the
SendMessagefunction to invoke the method in React:
// Call the method in React from Unity
gameObject.SendMessage("myReactMethod", "Hello from Unity!");
In this example, gameObject refers to the GameObject in Unity that contains the script responsible for sending the message. "myReactMethod" is the name of the method defined in your React component, and "Hello from Unity!" is the data being sent.
- Set up the communication channel in your React component using the
unityContext.on()method:
unityContext.on('MessageFromUnity', (message) => {
if (message.method === 'myReactMethod') {
const parameter = message.parameter;
myReactMethod(parameter);
}
});
In the above code, unityContext.on() listens for messages coming from Unity. When a message is received, it checks if the method property matches the desired method name ("myReactMethod" in this case). If it matches, the parameter property of the message is extracted and passed to the corresponding React method (myReactMethod() in this case).
By using the SendMessage function in Unity and setting up the communication channel with the unityContext.on() method in React, you can call methods in your React component from Unity and pass data between the two environments.
Remember to replace "myReactMethod" with the actual name of your method and "Hello from Unity!" with the data you want to send.
- I found this by asking to gpt, doest is sound right? most of the other replies about the topic werent that much....
Also what should be my address in
WebSocket ws = WebSocketFactory.CreateInstance("ws://echo.websocket.org");
Yep! looks like you've got pretty much most of what you need to get unity to talk to your js/react component
The websocket link I shared is just a library I used before to kinda show the layout of how unity can talk to javascript code
you don't need to use any of that unless you're trying to make a websocket
I just need to send a string
So does the guide I posted could potentially work? In that case it basically need to be set from react and I'll just do a normal SendMessage call with that method name
Yeah it should work
Can anyone help me. I am having an error when building my project in webgl
is there a preferred way to run webgl games on a local server? or a free server people like to use?
Primarily Build and Run. Unity provides configuration templates for Nginx, Apache and IIS. Not sure about IIS, but Nginx and Apache at least are free.
Some probably test their WebGL builds with their Node.js website development setup.
thanks...i'm using some visual studio code trick rn that I saw on the forums
If have a strange issue on webgl regarding audioclips:
I request an audio from an api through a WebRequest, I even receive it and im able to play it in an audiosource BUT when running on webgl if I try to debug.log its lenght I always get 0 while on editor the value is correct
To reproduce: 1) Open attached project and scene (corrected one with scene saved) 2) Play it on Editor 3) Press the button and uploa...
at least 5 years ago this issue was tagged as "will not be fixed" ๐
Please if somebody knows how to solve this issue let me know.
Could try submitting another bug report to get a second opinion
I can confirm that you can download audio and play downloaded audio clips as long as you make it simple. WebGL does not have multiple audio channels, so you will need to simplify stuff
Thats not my problem, I already did that part. The issue is the audioclip.lenght being 0
Do you know where? I can't find any submission section on that site
Ok I reported it trough the Unity Hub app, hope it will be noticed
Hey all! Today, I tried exporting a Windows Game I made yesterday into WebGL for itch.io web support but Unity didn't let me export the build and gave me this error. I don't understand what it's saying, any help?
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <dc14d30a5e0540ee9311ed6df63d9074>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <dc14d30a5e0540ee9311ed6df63d9074>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
I would have created a proper repo through Unity Editor to increase the odds of getting past QA
That in itself is just the high level build code exiting with errors. I would check the logs for any potential extra information.
I found this line, it looks like it could be the issue? Freezing tundra.dag.json into .dag (.dag file didn't exist)
Probably not though, I'll keep looking around
@orchid bridge Yea it's not guaranteed that you'll find anything. Next I would probably try building an empty project to make sure the build environment works.
Does anybody know why i get these Error trying to built my project?
Unity 2021.3.15
Could you try the latest 2021 lts version to see if it's a unity bug?
Does the Audio Low Pas Filter not work in webGL? Works okay in the editor.
I did a nice job setting up some audio occlusion only for the webGL build to ignore it.
2021.3.15 is lts ๐ฆ
Yes bru 2021.3.28 has been out
i will try XD
Hi Good Day everyone. Hi I have created multiple games and published in google play. What I'm planning right now is create a web based game like eduten. My first question is does anyone knows what game engine is eduten made of. second question is unity webgl performance same as phaser game engine ? Third question is will unity webgl support browser games in PC and mobile? Thank you
I'm trying to post my game online, but for some reason, the html version doesn't load cutscenes properly (the cutscenes are mp4 video played through the main camera and on the html version they don't play, it just gets stuck) and also the UI gets all messed up when it's not in fullscreen. How do I fix these issues? I'm not very familiar with how this WebGL stuff works.
Not sure about video stuff, but you can easily test your UI responsiveness in editor by changing your Game view resolution to free aspect, undocking it and resizing it around.
I resolved this issue, turns out that since WebGL has a different way to process audio the lenght and samples were 0 cause even if I generate the AudioClip succesfully the system wasnt able to analyze its data instantly, aproximately it took 0.003 seconds so I've just wrote a wait for seconds with a value of 0.01f between getting the generated clip and reading its values
To be clear I could have used a (while != audioclip.state.loaded) with a timeout but I'm afraid that a while loop could impact the performaces in a more significant way
So i've tested by creating builds in unity 2019, 2020, 2021 and 2022 of just a new project with the sample scene, Everything loads fine when i host the builds on itch.io but when i try to host the builds on the server at the company where i work the build just hangs past unity 2019. Unity 2019 and earlier work fine but 2020, 2021 and 2022 get stuck like you see in the screenshot there.
Can anyone think why this might be the case?
Ah never mind, got it working now. Just needed to update the web.config file
yes you are totally correct ๐ tho it teaches something very important, that one needs to know about differences between platforms.
What was the Solution?
I have the same issue
Still didnโt find the solution
Someone can help please
Always check the browser console for errors and share them
why is this happening?
Since the file is packaged with the suffix.data, the server cannot parse what type it is. Therefore, you need to add a MIME type to IIS.
add this
i've added it but for some reason it's still giving me the same error message
Hi all. I'm in the planning phase of a new project and looking for guidance on repository/project structure. The stack will be a React frontend with Node.js+Koa backend all to serve a Unity WebGL build. I chose this stack specifically because of a potential job opportunity and seeking to build familiarity. It seems like I could just have a single repo with frontend/backend/unity folders, but I'm curious if there's a best method or wisdom that could be shared for a project like this--I don't know what I don't know. Thanks in advance.
The alternative I thought of is to separate out the Unity project, and serve the build files from some kind of hosting/cdn. Then develop the React/Node.js+Koa application completely separately
Dang thatโs more than a year ago lol, yeah I did
But I have no idea what the issue was or how I solved it
I think I contacted my hosting provider with the issue and they changed something on their end, I remember it taking absolutely forever, because the customer service team was middle manning and had no idea what they were talking about
Just like the error says running webgl builds without a server is not supported and it's not meant to be supported
I hope you haven't been trying to do only that since 2019
idk why I never realize that it should run by xampp
anyway how to treat responsive webgl content in general
like multiple virtual smartphone device seems not fit with my sizing
hi friends, Did Unity get rid of the "streaming assets" folder on the web gl build?
I am not seeing it when I make a web gl build
thank you for any help
I'm not fully sure how it works, but I think you can use it if you use WWW (or maybe webrequest) to read the files.
At least this worked in 202lts
30MB isn't super unreasonable, especially if you can load some of it between main menu and gameplay. Addressables is a pretty easy way to get started with this.
There are build size report tools for a more detailed size breakdown
thx I will search Addressables
is there any reccomended resolution for webgl apps? I noticed that the higher the resolution the worst framerate I get
and its a bit frustrating cause even if the whole rest is optimized I still run low fps
is this from memory allocation ?
Yes and no.
No, couz browser window can get any resolution as it is re- scalable and it will adapt to that resolution. As you can setup your quality settings to scale 1/4th of resolution that is requested. There are some ways to workaround it.
If you add mobiles you have even more resolutions and problems.
Yes: if you aim at iOS devices as well, you can target resolution that their view port scale is smaller (390 x 844 for iOS 14 ) that actual resolution of the device, so you could aim at that. Decide minimum device you want it to run and set resolution to that device
by the way I also add Ration problem to resolution as well ๐
Optimizing on webgl is another story tho. Things can run smoothly on pc aka "optimized" does not mean it is optimized for webgl. I can give you example: video streaming on windows use 0.5% cpu usage of the game. On webgl it becomes 75% of cpu ๐
wow... 75%
luckily is pc only
you are lucky then, at least you can connect profiler normally ๐ but in general I would in your place set multiple quality levels, with different resolution. Then in order to limit rendering resolution you will need that in html actually, as unity takes that data for scaling on webgl. Or you will need to find where it does that and remake it.
I connected the profiler but noticed the most of the resources are used by "Other" 
Well GPU profiling is not available on build version if I remember correctly. Tho they updated profiler in 2023 so it might be old information.
have you also tried Memory profiler? It can give quite interesting information!
In general my rule of thumb is I profile in Editor or Windows build, then results I get divide by 4 and that is expected performance on webgl. Also have in mind multithreading don't exist on webgl and etc.
But for video best would be if you woould sjhare screen shot, link, or at least your settings in your quality options and rendering options.
Here's my rendering options
is there anything I can turn off?
Also I'm having a big issue that can't figuring out how to solve:
Looks like the WebGL app "steals" all the keyboard input so I can't write anything on external forms in the same web page
If found this
UnityEngine.WebGLInput.captureAllKeyboardInput = false;but it gives error when playing or building
What error?
GameManager.Awake () (at Assets/Scripts/GameManager.cs:25)```
any idea on why I get this?
hi there, ive been making my very first 2d game for webgl. ive set the background color of my camera to be lightpink but in the webgl build it turns into a dark orangish shade. moreover theres random flickering usually when im moving my mouse around. could you suggest a fix?
About my issue I found this
Can i deploy a unity WebGL in Docker?
Fixed the issue. Heres the game :https://nachiketh-vinay.itch.io/fb
Everytime i play again it lags a bit in the beggining. How can i fix this issue... I would love some feedback :)
It seems to be lagging when the pipes initially spawn in, how are you spawning the pipes? Also, the music seems to play multiple times if you spam the 'play again' button quick enough lol
I made a prefab and used instantiate to spawn a pipe at a regular interval and a movement script on every pipe object to move it right to left and then delete when it goes off screen
it actually seems pretty inconsistent, but the music definitely only starts playing after the lag. Might be loading the music every time. Do you play the music even when it's muted or still play it just at 0 volume?
Haha i didnt know about the music bug ill try to fix it
I have to music on a separate game object... I disable it when the mute is enabled in game
Maybe its the wwise sdk... They warned me about it being experimental... The addressables seem to lag my offline builds aswell
could be the ambient sounds being loaded or just the sdk in general. It seems like all of the sounds don't start until after the lag spike
Oh yeah the wind loads everytime it plays
Is there an alternative to keep the ambient stuff... The event that triggers it lies within the playmode scene so whenever we click play again it stops and repeats
You could make it DontDestroyOnLoad (https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html) and make sure to reset all the values when you reload the scene (if you are reloading the scene). That seems kinda janky, but for this simple game I think it'd work (if the ambience is the problem)
wel it really depends on your game, but for webgl I think you shooting a bit too high. that is really hard to make game look good and smooth on webgl. In your place i would reduce render scale, maybe even disable MSAA, reduce shadows as much as possible. Try using default low profile instead of high, and check if it improves your performance to targeted specs. then increase things to look as good as possible. what fps you are getting in game you running now?
this is not the high profile but one that I made by myself, is mistakenly removed the default ones, is there a way to get them again?
for the rest thanks for the suggestion, I'll change the settings
Hello! I've been running into an issue where I'm trying to make an API call to my backend for authentication purposes, then set a cookie in the browser. Problem is, I still end up being able to extract the cookies in the Unity editor, but not in the webgl build in the browser. There seems to be a known issue where WebGL where it does not allow headers to be set.
I tried to overwrite the javascript fetch function in the build html script as was done here in this guide https://stackoverflow.com/questions/72404284/unitywebrequest-webgl-missing-cookie-response-header - but with no luck.
I still end up being unable to read the header in the browser.
Has anybody experienced this before or have any idea how to fix this?
What exactly do you mean by reading the header? You can't read cookie headers directly, like the SO answer says
Does Linux os has any difficulty building unity webgl apps?
I'm using a line containing "WebGLInput", on my local Windows machine it build normally and the app works but on an AWS container that runs on Linux it fails
Fails to build? I never build it on Linux machine so I am not sure. My guess you are missing some libraries like: Git LFS, or make sure your unity version is the newest, as there were some bugs in older versions (https://issuetracker.unity3d.com/issues/linux-webgl-build-crashes-every-time-when-using-unity-editor-on-linux). Question did you just coppied project to linux from windows system? if yes, then delete project/Libary folder, and let it rebuild it when you next time start unity.
For cookies I think you will need to use Jaascript to pass that data to Unity. At least we do so, so I guess there was a reason ๐
You can easily set headers
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.SetRequestHeader.html
and read them
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.GetResponseHeader.html
I have a problem with the video player for WebGL. I got it working fine with no issues on one project, but on another the video just refuses to play. This only seems to be an issue on Firefox, and the video plays just fine on Chrome. The first project loads a video just fine on both Chrome and Firefox. The second project can play the first project's video just fine, but not any other videos (so not a critical problem with the second project's video playing system). The second project also fails to play shorter videos (so size isn't an issue).
It seems like there's some issue with the format of the videos or Firefox's WebGL just refusing to play some types of videos. I've tried building in multiple versions of Unity (2021.3.24f1, 2022.2.12f1, 2023.1.5f1), all of which fail to load the video.
Any insight would be appreciated.
Both projects have the videos after you hit start.
Project 1: https://machasins.itch.io/cornered
Project 2: https://machasins.itch.io/discord-mod-simulator
Yeah I uploaded the project I locally develop on Win but without the Library folder since its not necessary for the build (it will get generated again) and so I save upload times
The thing is it normally works fine, then I added that line of code and suddenly it fails to build
did you install Editor on linux with webgl platform modules from Unity Hub? I would assume you were using it and not console interfacce. if console interface are you sure while isntalling you told it to install webgl stuff?
It should yeah, I uploaded a premade container to build in aws:
https://hub.docker.com/layers/unityci/editor/ubuntu-2022.3.2f1-webgl-1/images/sha256-70498904be61f9828c358068d03cc6add9d8c1cc11b6a5ae0eb1379b4dc97265?context=explore
btw this is a post that should be related to this issue:
https://github.com/kou-yeung/WebGLInput/issues/94
Your webgl Is non multiplayer right? As I would teest if it builds non webgl builds
no its not multi
wym with the second phrase?
oh right
It does
but that specific line mentioning "WebGLInput" need to be in a #ifWebGL check
cause its a library exclusive to that platform
Sounds very much like Unity bug then. You could try report it to Unity.
As if it is in #IF UNITY_WEBGL and build on linux, that means it does reload and recompiles scripts before building. As you would get errors where you have #if UNITY_SERVER or something like that. I dont even know if you can recompile scripts on code lines :
Keep in mind it shouldn't be an issue specifically tied to that #IF UNITY_WEBGL, I tried putting inside of it just a simple debug.log and it build sucessfully
Then most likely it does not have WebGL libraries for some reason. Have you tried reinstalling unity?
not yet
but is it possible that it builds a webgl game without these said libraries?
Did you see the last post on the link you posted?
yeah I tried updating the building code with the one the guy suggested but the issue persisted
I believe we have used multiple editor instances to build for each platform. Starting Unity with the target platform might work better?
The unity inside the container should aleady be set to web plus I set the build target to that platform in the buildscript too
at this point the only thing I can think to try to solve this is to switch the virtual machine in the container from Linux to Win to see if thats the issue...
{
#if !UNITY_EDITOR && UNITY_WEBGL
WebGLInput.captureAllKeyboardInput = value;
#endif
}```
this is the line of code giving issues btw
damn it sucks when the issue is so nichey that there are no posts around
also this was the output log on build fail on the AWS container:
1
##### Output
Assets/Scripts/WebManager.cs(203,5): error CS0103: The name 'WebGLInput' does not exist in the current context
*** Tundra build failed (9.53 seconds), 374 items updated, 479 evaluated
## Script Compilation Error for: Csc Library/Bee/artifacts/2000b0aP.dag/Assembly-CSharp.dll (+2 others)
## CmdLine: "/opt/unity/Editor/Data/NetCoreRuntime/dotnet" exec "/opt/unity/Editor/Data/DotNetSdkRoslyn/csc.dll" /nostdlib /noconfig /shared "@Library/Bee/artifacts/2000b0aP.dag/Assembly-CSharp.rsp" "@Library/Bee/artifacts/2000b0aP.dag/Assembly-CSharp.rsp2"
## Output:
Assets/Scripts/WebManager.cs(203,5): error CS0103: The name 'WebGLInput' does not exist in the current context```
@astral wave Did you see anything wrong? (sorry for ping)
It seems like you just lack of some specific libraries. But question why it does not see it for your build.
I had these errors on windows, when my Visual studio code were missing libraries installed.
Could it be specific Linux version that causing problems?
I should since as far as I understood the libraries gets generated each time the build performs
it does not generate netcode and others. If your system dont have you will get errors.
So I should try to also import the library then
@astral wave just to keep you updated on the case, this time I've also uploaded the Library folder to the container and so far seems that the build pipeline completed successfully, at this point I guess that Linux has difficulties at creating some specific libraries. Thanks for the suggestion!
can anyone help me with this please ? i got this error and i have no clue why , i got the error while trying to make a webgl build (it solved itself, idk how)
restart your computer and try again. this happens when building proccess did not succeed to finish and you start to start new one. YO ucan kill proccess if you know what it is, but restarting pc will do the same.
Is webgl2 noticeably more resource intensive than webgl1?
is it really adding custom .https will get rid this notification ?
from what I understood Webgl2 is just superior in everything over webgl1. It just webgl 2 support more features than webgl 1. if you dont use those features it will perform not worse than webgl 1.
Plus new unity versions officially DO NOT support webgl1 anymore
From Unity 2022.1, the Auto Graphics API setting no longer includes WebGL 1 Graphics API.
You can manually add it back, but with your own risk.
https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html
If you follow documentation it does remove this message.
Have in mind brotli, gzip needs seperate configuration.
https://docs.unity3d.com/Manual/webgl-deploying.html
oh ok thanks
I randomly discovered WebGPU few days ago, I hope Unity will implement it soon since it seems fixing the big graphical limitations that webgl has
Pretty sure it's already being worked on.
It should be, I read about a unity dev saying time ago it was planned for 2023.2 experimental but I guess it got pushed further away
it's oky just upgrades it to 2021, solve it
but I do disabled tho,
and wondering why we should use brotl or gzip ..
Brotli certainly compresses better. I don't remember what the runtime characteristics during decompression were.
how do I solve this issue
okay so finally after like 10 hours I managed to solve this issue
if anyone gets the same issue next time, basically you want to enable name files as hashes
I have a webGL build with Input fields (UI Toolkit input fields) but the problem is that when i run the build on mobile i can't type, the mobile keypad does not pop up, what can i do about this?
Is there like some kind of internal unity code i can call to have the mobile keypad pop up?
almost everyone I know just uses this:
https://github.com/kou-yeung/WebGLInput
From what I understood unity supports keyboard only on mobile build, but webgl build is not considered Mobile so thats why. Maybe someday it will work by default, someday.....
404
URL got pasted twice https://github.com/kou-yeung/WebGLInput
thanks ๐
When sending a webrequest, what's the difference between using a yield return null and an async request to wait for a response?
Is one of the 2 approaches better in terms of performances?
-
On webgl you will get same performance regardless, as you have only main thread anyways.
-
Async give you higher control, from letting you return values or pass interuption tokens in cancel webrequests and etc.
-
While async works, but most threading features does not work on webgl. So you will find weird behaviors like something not working without errors and etc. Unless you use UniTask (https://github.com/Cysharp/UniTask) which lets you enjoy all tasks features and queues of tasks and etc.
So in short, you will get no performance gain and webrequests if you download any textures or something bigger HUGE part of CPU. You will get no multithreading anyways. But I personally like Async way more, with hope someday native Tasks and multithreading will be available and I wont need to rewrite most of the code.
There are tons of forums about Coroutines VS Async, in general Coroutines have less overhead, but that difference is not that huge. So if you need something to Run and forget, use coroutines. If you need something returned? like did request suceeded and etc, then async functions more helpfull.
sorry that I put more than async vs yeld. But with webrequest you will most likely will need a bit more than just that.
ok thanks for the explaination ๐
I think with unitask lets you return stuff, it's really handy overall and pretty easy to use once you get the hang of it
Could it be that itch.io webgl is limited?
everytime i try to spawn in it crashes with a error
Pls dm or tag me if you can help me
Browser's console prints logs
exception thrown: RangeError: Maximum call stack size exceeded,RangeError: Maximum call stack size exceeded
Infinite loop? Do desktop builds work?
I agree, UniTask is very convenient. It can return values just like native Thread tasks, and pretty much have all features with very similar names as well. So it is simple to learn and understand.
what's the difference between PWA and minimal
I'm having the game hosted on itch.io
I think PWA is the newer one, default is the older one and minimal is compression to reduce program size
Idk tho
Never used web gl
read the docs: https://docs.unity3d.com/Manual/webgl-templates.html
PWA allows players to install an executable of the game on their desktop, so that the game is accessible similar to a native desktop game. So instead of opening a browser, typing a URL to access the WebGL game; players can now click on the icon on their desktop and it launches the game right away.
Try https://ev.io, it's a good example. You should see a pop-up prompting if you want to install on your desktop.
It still runs on broswer to me, no pop-up appeared
ah OK, maybe they don't have the prompt enabled. Try this if you are on Chrome: Top right look for this Install icon, that should do it. Once you see the icon on your desktop. Try closing your browser windows and launch it from the desktop. You should see all the Browser navigation stuff removed and only just a dedicated window for the game. (P.S. it's still technically running in the browser in this new PWA window, just it's modified to look like a navtive desktop application)
I'm personally really excited for what PWA means for the future of web gaming + WebGPU. I think we are going to see more high quality games hitting the browser platform in the very near future.
since its "installed" does it have more resources to work with and so better performances?
I know that with PWA when it comes to Web Application, it gives developers the ability to cache more data I think and implement offline features. So technically the app could work offline, commit changes like "post a message into queue" and when the app comes back online the message will automatically submit. Stuff like that... I don't think we are going to see a huge performance boost for Web Games until WebGPU is supported. I think PWA can help with performance a-bit with the cache features I mentioned and something known as service workers. But you'd have to dive deeper into that to figure out how to benefit from it for your particular game.
there doesn't seem to be much detail though in the docs... all it says is "PWA: A Progressive Web App including a web manifest file and service worker code."
It would be nice is Unity added more details on how to take advantage of Service Workers, and how PWA would benefit a web game. Like the example I provided above, it's a nice feature to add to your Web Game. Having the option for players to install it on their desktop.
Ok thanks for the info
Then I'll keep praying for WebGPU arrival since now the only things that bothers me about WebGL are performance issues
I hear a-lot of people complain about WebGL performance issues, but when I see a game like https://bapbap.gg we have to ask how much of the performance issues we complain about is simply a matter of being lazy and not optimizing our game very well ๐
If you tried developing for WebGL a few years ago, I'd totally validate those complaints as it was truly a struggle then. Today it's gotten soo much better. I'm currently pushing 32-48 players in a multiplayer game on WebGL using Mirror Networking and low-poly style, with tons of messages, and special fx, sound fx, all being played back at the same time with pretty good performance. I'd be happy to show some live performance stats with my project maybe in a few days.
Of-course if you are trying to create a game that has a lot of heavy textures, and high poly counts, you'll for sure have an issue. In these cases I totally understand the complaint. Although I would have to ask, what's more important "Fancy Graphics" or "Quality Gameplay" if you say both, then WebGL or maybe even WebGPU may not be the platform for you. Mobile & PC is probably more your platform if you want less technical limitations.
For sure there's always something to optimize but In my case the scene its pretty simple and mostly static with a couple of script running in background, maybe the polycount is a bit high but the main issue is mostly on low end pcs. I heard the the general webgl rule is "look the FPS you get in editor and divide them by 4" and I kinda agree
How low of computer specs are we talking?
Our full-service platform empowers game developers to find success on web. Get your game out to millions of players and get paid in just a few steps.
I guess 300โฌ laptops
this is an awesome device specs report by Poki.com that shows you specs based off of 50 Million Users on their game portal site. Based on this report about 80% of users have CPUs with 4+ cores which I think means at least 2GB - 4GB of Ram at minimum. Which is a a minimum requirement for WebGL games to run. So as long as your game is optimized to run on 4 Core CPUs and 2GB - 4GB of ram you should be good!
Hmmm what is that like a really cheap netbook / Chromebook or something. The above report shows only 6% are running Chomebook OS. Which means not many people are playing WebGL games on such low end devices.
Also for that low of a price, I don't think a laptop comes equipped with a decent graphics card to even run WebGL properly. You may be over thinking it, and trying to target such low-end devices with a userbase that is almost non-existant for WebGL games.
although I can totally see the chicken or the egg problem here... if no WebGL games are available that run on such low end devices then yes, obviously the current market share is lower. I think it's easier to work with and build for the existing known market share vs trying to establish a brand new market of players though.
I agree but currently im developing an edutainment app that corporates provides to its employees, it must be on WebGL since its basically a front-end where all the logic part is handled by the site itself
And since 90% of these users are boomers they will have a bare minimum pc
@random talon You may want to try Three.js then... https://Hordes.io is the only browser MMO built on a custom version of Three.js that can handle hundreds of concurrent connections within the same scene with OK performance. Otherwise with less concurrency in a scene the performance skyrockets probably out-performs Unity WebGL by a ton!
I don't know of any good benchmarks to show the difference but I know when I try to push my current multiplayer game concurrency close to 60 - 100 players performance is horrible. So I can only push 32-48 comfortably at this moment.
It's a tradeoff i'm willing to live with for now because productivity is much higher and I can get things done faster in Unity in comparison to working with a JavaScript Library that you have build almost everything from scratch.
https://playcanvas.com is another great option that may perform better than Unity WebGL.
The app is singleplayer so I have no issue on the multiplayer side
in this case you really should have have no problem optimizing the crap out of it to run on lower end PCs as long as you keep polys low, and minimal textures. In my project, I only use 1 Texture and 1 Material that has a palette of colors which is then mapped to all objects in my game. So this results in 1 draw call. If you are already doing this awesome! If you still see performance issues I think you'll have to really optimize the code then, using Unity Profiler should be a good tool to find spikes in performance on code running.
If none of this works, and your $300 laptops are running your single player WebGL game with crappy performance shooot!! Yea, you may be out of luck and may have to try alternative WebGL game engine / library.
Yeah as mentioned it should run fine on that if optimized well (we do a ton of edu sims for VR and web). But yeah, in lots of cases playcanvas or threes.js or Babylon or some raw webgl library is always a more performant way to go.
We've had to do some dark magic with unity webgl for low end devices before, including manipulating and pausing rendering.
Was anyone able to run URP in WebGL. Not sure where to write, but I tried to create a URP project from the template, switched to WebGL and tried to run it, but I'm getting errors. It runs if it's a Release build, but not a development one
If it is or will be public, please share, I would be super interested to see more well optimized projects and learn from it ๐
Please write Unity version at least. But in general URP does work on webgl for sure. well maybe not every feature but most of it ๐
Thanks for the reply. This is my version (the latest LTS)
2022.3.6f1.0.15644
Revision: 2022.3/staging b9e6e7e9fa2d
Built: Tue, 25 Jul 2023 15:03:37 GMT
is netcode for game object support webgl build
hello I'm experiencing issues regarding 3d audio blend on webgl builds in 2022.3.4f1 and 2022.3.7f1, it is simply not working.
https://issuetracker.unity3d.com/issues/on-webgl-player-spatial-audio-3d-sound-settings-does-not-change-direction-from-where-the-sound-is-played this bug is supposed to be fixed according to the issuetracker
works fine in editor on windows/windows build
How to reproduce: 1. Open the user's attached โNew Unity Project (1).zipโ project 2. Open the โSampleSceneโ Scene 3. Switch platform...
I experienced issues with sound on WebGL as well in version 2022, so i'm currentlty still on 2021 partly because of this.
do you mind telling me what version you are currently using?
Hmmm, then there should be no problems. Could you share error codes? I would try to delete Library folder and start project again, let Unity rebuild library folder and check if problem still there.
Unity Transport 2.0 and above supports websockets. Webgl uses websockets. so it should be fine.
I was able to get URP running in WebGL (There are quite a few inconsistencies that I'm going through now) However the steps that I shared are for a brand new project. After using the template I just check development mode and clicked Build and Run
without error can't help anything. It builds without problems for me. so thats why asking ๐
I understand. Here is properly submitted bug:
Steps to reproduce:
- Create Project (3D URP)
- Switch platform to WebGL
- Check Development Build (without this step it's working fine)
- Build and run
Expected result: See the application in the browser
Actual result: Error: (Sorry for the screenshot, for some reason it doesn't let me copy the string from the message). I have 64 GB memory and around 20 is free now
Stack trace: Uncaught RuntimeError: memory access out of bounds
at UniversalRenderPipeline_SetupPerFrameShaderConstants_m9CE3FEB386B87C56438021D38AF3ACF7936293A9 (Temp.wasm:0x7eaf93)
at dynCall_vi (Temp.wasm:0x1e2d30a)
at Temp.framework.js:1796:22
at invoke_vi (Temp.framework.js:16638:5)
at UniversalRenderPipeline_Render_m15A42AB44C14AB4DCA7EF0B915964D46B643D50E (Temp.wasm:0x7e9508)
at RenderPipeline_InternalRender_mCB77395158F4572F348D8227BA9127ABF1C9C5BE (Temp.wasm:0x31a492)
at RenderPipelineManager_DoRenderLoop_Internal_mB646C8738F4A9859101F3BE94809E2E10BBDB1FB (Temp.wasm:0x31b8e4)
at RuntimeInvoker_FalseVoid_t4861ACF8F4594C3437BB48B6E56783494B843915_RuntimeObject_IntPtr_t_RuntimeObject(void ()(), MethodInfo const, void*, void**, void*) (Temp.wasm:0x131268f)
at il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) (Temp.wasm:0x1358922)
at dynCall_iiii (Temp.wasm:0x1e2d2f8)
at Temp.framework.js:1796:22
at invoke_iiii (Temp.framework.js:16649:12)
at il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) (Temp.wasm:0x1354a12)
at il2cpp_runtime_invoke (Temp.wasm:0x135a481)
at scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) (Temp.wasm:0x1dd5d61)
at ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) (Temp.wasm:0x1d7432c)
at ScriptableRenderContext::ExtractAndExecuteRenderPipeline(dynamic_array<Camera*, 0ul> const&, void ()(SceneNode const, AABB const*, IndexList&, SceneCullingParameters const*), void*, ScriptingObjectPtr) (Temp.wasm:0x15555ba)
this error is quite not readable. It is way better to press f12, open browser debug console and then press ok. It will write all code there.
Stack trace: Uncaught RuntimeError: memory access out of bounds hmmmmmmmmmmmmmmmmm
what is your maximum memory set on player settings?
I know those are hard to find, let me know if I can help with anything else
I didn't change anything, these are all the steps I run
hmmmm, have you tried deleting library folder yet?
I can do that, but it was a brand new project in a new folder
it might failed build webgl Libraries when you switched platforms.
make sense, doing it now
That "fixed" it. ๐
@astral wave : One more question: If I start the webGL app before the canvas is displayed it throws error ([.WebGL-00001B017D343100] GL_INVALID_FRAMEBUFFER_OPERATION: Framebuffer is incomplete: Attachment has zero size.) . That only happens when I run it with URP, It didn't happen before. And if I keep the app on the screen it doesn't show. The reason I don't want it display, as there are some addrassables that takes time to load and it doesn't look good
There is several approaches. You can handle this on JS and html side. But most likely for that you will need to hide canvas without changing its size (resolution), as unity needs that info to create loading. You can then create event that on Addressables done loading you call JS and show the Canvas.
I personally went with more stupid brains way. Create Initialization scene, which have "fake loading screen image", and load all addressables things then. And when done I change I unload that scene and forget about it.
Thanks! Appreciate the help!
2021.3.7f1 LTS
I'm currently trying to use https://github.com/FunkySheepStudio/Unity-Network/blob/master/Runtime/Lib/NativeWebSocket/WebSocket.jslib in unity 2022.3.4f1 and am getting this error when running a build: textEncoder.encode is not a function, presumably because the associated module isn't being used
How do I make this work?
just tried this version as well, not working either... am I the only one on this planet using spatial blend on webgl ? ๐
here is a reproduction project with a camera moving around an audio source, if someone could tell me what's wrong...
are you trying to hear sound based on the distance... so the closer you get the louder it gets sort of thing? I've never heard of spatial sounds before but if that's what you are trying to achieve then I think it should totally work, as it's working fine in my project. But I'm sorry I don't have the time at the moment to dig into it to see how my setup is in comparison to your project.
reading alittle on what Spatial Blending is morph between the two modes of 2D an 3D sound I guess you are doing something different than what i'm mentioning above. In this case, shoot sorry have no idea about this sort of thing ๐
I guess in my case i'm only using 3D Sound, and you are trying to blend between the 2 modes. I guess maybe ask yourself if blending is really necessary for your game?
3D sound varies based on distance, 2D is constant no matter the distance of listener. I would think we all want 3D sound for 3D Games no?
I figured out after 2 horrible days of debugging ๐ when using a video player and outputting the audio to a audio source (the only way to use 3d audio of a video player, using only ui at least) effects like spatial blend won't work. https://forum.unity.com/threads/webgl-spatial-audio-for-videoplayer.947112/
according to employees that have replied to the thread it is not a bug but a technical limitation that was supposed to be looked into in aug 2020 but no updates since then
Hi again!
The limitation of audio mp3 streaming seems to be one imposed by Unity, not by the browsers, possibly coming from an era where this wasn't broadly supported (just guessing here...). We'll test it out and remove this restriction if everything works out. It's been pointed out earlier: https://issuetracker.unity3d.com/is...le-in-editor-with-build-platform-set-to-webgl so it's already in the todo.
Looking at the current code, .wav may work but streaming of uncompressed audio is not a very exciting solution.
So for the time being having a built-in audio asset (not streamed) and a video stream seems to be the other compromise that's available to you.
Sorry for all the trouble... Hope you find a way to your goal; let us know how this goes and we'll see if there's anything we can think of that can help.
Dominique ```
there could be a warning about this because some people like me are stubborn and spend hours and hours trying ๐
ahh shoot! yea that would be helpful for sure... i feel ya pain!! ๐
will take a chill pill for today and see which alternatives I have tomorrow 
I'll open a issue on the bugtracker
hi
i have been trying to send email through webgl but nothing seems to work
can someone please help me
i made a application that detects face and u can change glasses , i was taking screenshot and sending that through email it was working fine, but when it ried webgl it doesnt work :((((((((((
depends on which functionality you are using, some aren't available for webgl, most of the time because of technical limitations. try search for forum posts about your specific issue or api documentation about functionalities not available with webgl.
Thanks
Sending emails directly through WebGL is not possible as it doesn't have direct access to TCP which is required to send emails.
You would need to send a request from WebGL to a custom Webhook or API that handles it.
I would personally use something like NodeMailer https://nodemailer.com/about/ and Cloudflare Workers https://developers.cloudflare.com/workers/ or Firebase Cloud Functions https://firebase.google.com/docs/functions to handle this.
Nodemailer is a module for Node.js to send emails
Cloudflare Workers provides a serverless execution environment that allows you to create new applications or augment existing ones without configuring โฆ
Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests.
Dear friends, what would you suggest for cloth physics on webgl?
- just generic unity cloth?
- fake bones for cloth and just mesh deformation?
- any asset you know that works well?
- any other ides?
@sweet oriole suggested Flexi-Motion to me a few months ago. I'm pretty happy with it. I was previously using Dynamic Bone. Flexi-Motion definitely performs much better and provides much better physics simulation in comparison to Dynamic Bone. https://kybernetik.com.au/flexi-motion/
Unfortunately Unity Cloth is not supported on WebGL, so using an asset like this for now is our only option I think until maybe WebGPU is supported. I think WebGPU will give us cloth physics support and much more i'm pretty sure.
Thank you, will investigate it. Looks like great tool!
Tho what do you mean Unity cloth is not supported on WebGL? as this simple test seems to work. I guess will need to investigate more.
I can't seem to find documentation on it, but I could have sworn there was some limitations with cloth and WebGL. Try Unity Cloth on a skinned mesh character that has some clothing attached and put the character into animating walk cycle or something. If that works, shoot then i guess i'm crazy lol!๐
hi guys
I cant create my webgl build anymore
it was creating the build perfectly 2 days ago but since yesterday i can't
it creates build for other platforms just fi e
fine
ill share the errors i get upon build fail
please help me or if someone can guide me to fix the issue
BuildFailedException: Incremental Player build failed!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <a53e7cd0bf8c4035ac3e78fb7b43c4a6>:0)
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/build/output/unity/unity/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:179)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <a53e7cd0bf8c4035ac3e78fb7b43c4a6>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <a53e7cd0bf8c4035ac3e78fb7b43c4a6>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <a53e7cd0bf8c4035ac3e78fb7b43c4a6>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <a53e7cd0bf8c4035ac3e78fb7b43c4a6>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
That's not the full error log. You have 3 errors under one of your error messages that will tell you more
I usually have to do a full restart of my Laptop, and make sure not to launch any other applications except for Unity to have successful WebGL Build. This is mostly because WebGL build process uses a crap ton of memory. So if I have a-lot of apps open, I can't properly build until I free up enough memory. I have friggin 16GB of Ram and still my WebGL Builds give me issue due to not enough memory. Not sure if that's your issue here but try to do a clean reboot, and only launch Unity and try to build.
I tried this
earlier the build was taking around 10 to 20ish minutes and now it took like 1minute
but still it failed
it has 6 errors
it's only taking 1 minute now because I believe the build is cached; the new quick build time is based on only what has recently changed. If you delete the build it will take 10 minutes again... but you may want to try that as your previous build may be corrupted for whatever reason.
could it be because I changed the index.html file of my previous build ,
I added some buttons to it using html and javascript to manipulate stuff in unity using those buttons instead of unity buttons
but i removed that bit of code from it
so i should delete the build?
no any changes to index.html file won't affect your WebGL build as that is totally seperate thing. Unity just happens to provide you with a template index.html along with some basic styles.css. So if you made some changes to that, you may want to copy all of that to a separate folder. Delete your orginal build folder and try again.
1 min
okay
so my build folder is on my left... if I made changes to the Index.html and any of the data residing in TemplateData copy or move that into a new folder to save that!! Otherwise if you re-build you'll lose those changes
So after you move / saved your index.html and TemplateData to new folder. Go ahead and delete the Build folder before re-building
the after re-build if successful, you'll copy your build folder into your new folder that stores your index.html + TemplateData (in my case in the folder i called Index)
then test the WebGL Build from there
okay
thanks I'll try this
i have these folders here
i have a photos folder because my application takes screenmshots and saves them there
cool! this is where you are serving your WebGL Game / App from with your Local Web Server
so ill be moving index.html, streaming assets?
hmmm is your Unity builds set to build directly to this folder WebApp
I would just build it somewhere else, then after build is complete copy your Build over here (overwrite your Build folder here)
omg
it completed
i deleted the whole folder
and built in a new one
let me try it real quick
its not going any further than this
but atleast it created a build
hmmm that is certainly an odd looking game lol
but yea, cool progress!
check your browser console for errors
if no errors then maybe you screwed up your CSS lol
if you modified the index.html that the Unity WebGL build provided you with, keep in mind there is some style.css and other elements that it may be calling in TemplateData so if you didn't properly migrate that over then could be why your build is not loading.
no no
the game is basically a face trackign app with option to change glasses and send email
ah gotcha! cool...
i made the build again with build and run
it asled for camera access but then its back to this page
the title of the app isn't even this
so its probably not loading anything
?
sounds like you have a unique app you are building here with needing camera access and such. I've never worked with Unity WebGL for apps, just for games. So i'm not sure.
check your browser error logs and try searching that
trying it
cool!
You need to run it on an actual web server, but if you hti F12 and open the console it should show you what is happening.
For WebAR, I don't use Unity, as it just adds a heavy intermediate layer.
And depending what you are using, most Unity AR frameworks won't work on WebGL.
okay
ill give it a go
its giving error in index.html
i deleted all old builds and building in a new folder
As mentioned... you are missing TemplateData. Error is referencing Unity Loader which is some elements residing in TemplateData you need to properly migrate over into your webserver.
can you kindly guide me how can I do that? :/
You modified the original index.html that Unity provided right???
Then moved that over to your web server.
But you never moved the TemplateData over
yes but I reverted it back to what it was and then build was constantly failing
after that I deleted streaming assets and inddex.html
I had build but it never loads anything
When you complete your Unity WebGL Build what does the final build look like???
I mean within the folder that you picked to build to, what does that look like?
like this
Hmmm I've never seen that setup before. In my builds I always have TemplateData
should i do development build
i'm using Unity 2021.3 LTS though so I don't know if you are using latest version of Unity and what bugs that might have ๐
im using the same
that shouldn't matter... dev build only builds faster but outputs larger files.
What does your unity WebGL build settings look like, what Template are you using?
Player Settings sorry?
what Template
I have always used Default, and it should output a TemplateData
what should I show you from Player settings
which template data are you using?
also do you really need streaming assets? I believe this is a setting somewhere, but try disabling that just in case for testing.
ok
Try Default Template with Streaming Assets Disabled. Make sure the templateData is there then move all that to your webserver and see if loads then.
okay
Is here a good place to talk about apache errors when loading webgl?
I imagine you are trying self-host. Have you considered maybe Cloudflare, Netlify, or other CDN hosting solutions for static content (a.k.a WebGL Builds and related website content). It makes life so much easier than fiddling around with VPS, SSL Certs, and Web Servers. Especially if you want your game to scale properly. Self-hosting is really not very sustainable in the long term especially as a indie dev.
We self host (some our own bare metal) and have about a dozen servers - :). It's nice having next to nothing in server fees.
That said for just flat web servers, there are some great deals (I.e. stablehost @ 30/yr unlimited domains with softaculous). And places like itch.io.
I'd be interested to see the error @winged island might just be a mimetype issue or something easy to fix (I suspect you might not be self hosting but seeing the gzip issue, etc). I do agree though, early on especially, you probably don't want to learn server devops ๐
No server fees, but what about an electric bill? lol... Cool though! I take it Red Iron Labs has a few staff members? If so, then I guess self-hosting is manageable. But if we are talking about 1-2 man small indie dev teams, I would think focusing more of your time on your game vs managing infrastructure is more efficient.
Electric is negligible compared to AWS or Azure :). We've been bare metal since being two people in a basement though, but I do agree it is a lot for someone who isn't used to it.
I'm pretty sure I'm the only one who would find the topic interesting though:)
I do enjoy managing my own servers coming from a career in IT and now Full-Time Web Developer. But ya, as a solo game dev (by night) I need to offload some that work elsewhere. So I don't mind paying for it. I would never use AWS, Azure, or even GCP though lol! Wayyyy to expensive. Linode just recently dropped their bandwidth pricing to 0.01/GB... one of the lowest on the market maybe competing with Digital Ocean. I'm actually using Linode to host my Lobby Servers in certan regions, and then using https://edgegap.com for automated scaling game servers.
Linode and DO are both awesome providers ๐
Although I also prefer linode. DO has changed a lot over the years...
I'll check out edgegap.com - thanks for sharing
DO performance is lacking at least for Game Servers (based on some research I did), they are still pretty new to that market (perfectly fine for Web Apps though). Linode one of the reason I was sold on them is because they are now aquired by Akamai and one of my favorte games WarFrame uses them for hosting. So if they can handle Warframe MMO for 10+ years, I can count on them to keep my indie game dev severs online lol!
I was considering to build out my own auto-scaling game server solution on Linode with Kubernetes but after consulting with Edgegap, they were able to beat the hosting cost i'd be paying with Linode. On top of saving me the headache and time of building out my own solution.
Actually i was using irzcle free resources, but iโve fixed the error. I just uploaded an uncompressed build to the server and apache took care of the compression, that seemed to f#do the job
ah an issue with serving Gzip or Brotli compression... it can certainly be a pain to configure. I don't think I ever had much luck with that last time I tried lol ๐ ! Another reason why I've opted for using a CDN server because they handle that for you.
hey i fixed everything
its making build now and running things
but I want to try manipulating this html file that is made with the webgl build
I've tried everything (I can send email from webgl), but I couldn't find a way to send attachments in my webgl build, can someone pleasehelp me out with this?
Do you already have a way to send emails first? Do you have an API or Webhook you are hitting to trigger the sending of an email?
If so, the attachment is actually going to happen at the backend. You just need to figure out how to send the data you want to attach to the Email Sender API / Webhook and then handle the attachment there.
If you built your own email webhook then you'll need to add additional code for to handle this there, otherwise if you're using a known Email Sender API Service then they should have some methods for you to hook into, check their API documentation.
I can send the emaul without attachment but with attachment it gives error and ruins the project
The app
Im sending it through a javascript library
I tried asding attachment in that library but it causes the error and doesnt work
Ah gotcha! Yea, then in this case this becomes a JavaScript Library / Module issue you'll need to consult with the creator of that to assist you.
it would be outside the scope of this channel for that level of support possibly.
One thing I could say is just be 100% sure that the way you are sending the data is in the correct format that the library wants. As there are many ways to send data. Which can cause errors in uploading, downloading files if not formatted properly.
Can I show you?
That library gothub says it cant send attachments:(((
Thats what I want
Unity Plugin that allows sending emails from WebGL builds using the https://smtpjs.com/ API. - GitHub - hendrik-schulte/unity-webgl-email: Unity Plugin that allows sending emails from WebGL builds ...
There should be a wayyy
Its 2023 ๐๐๐ญ๐ญ๐ญ
HI
i have a problem
Assets\SelectFace.cs(23,45): error CS0176: Member 'CubeState.autoRotating' cannot be accessed with an instance reference; qualify it with a type name instead
nvm thx guys!
OK so this Library is communicating with https://smtpjs.com/ API to send emails. If you scroll to the bottom of this website you'll see that it does support attachements. But you will need to extend the code of this unity-webgl-email library to support sending attachments. For whatever reason the developers did not add it lol. So you'll have to add this yourself.
Send email from client-side javascript - free js library
Oh
Ill try this in morning in the office
Can you guide me a bit how I can achieve this
I will write a article once I achieve attachment email with unity webgl
So other people can fogure it out easily
keep in mind this Library is 5 years old, and the smtpjs.com maybe could stop working one day... as it says it's free to use. But nothing ever free forever lol! So expect it to one day stop working ๐
Omg
Atleast it will work for now
I wont be working for this compnay in 5 years xd
Though Ill keep looking for good alternatives
lol
๐
sorry don't have to time to look into this... I need to use my free time to work on my game ๐
Oh, what are you making?
i have day job, then work on my game in my limited free time.
I'll share it in #archived-works-in-progress maybe a-little bit later today
it doesnt work
sometimes better to create your own vs depending on an unsupported library.
I created a server and sent message (texture 2d, and email as string to it)
It worked
Now I have one thing
My manager gave me a html file with buttons
Hes saying to atart my unity app with that html (whenever u press a button it will open my webgl and trigger some functiom in my webgl)
Is it possible?
Shouldn't be an issue to wrap whatever Unity is doing
It should be standard HTML5 stuff up to the point you boot up Unity and interact with it
wait 30 minutes after eating before you swim
You can send raw binary through a websocket, and websockets are supported with unity/webgl. You could encode your presented file into binary, send it, and rebuild it on the other end
thanks
Is there a tris/verts count I should aim to for keep a good framerate?
These are the current stats (on editor)
I'm personally not sure what number of tris/verts you'd want to stay under to keep the best performance in WebGL, but I can tell you that paying close attention to the SetPass calls (which is also known as Drawcalls) is one of the most important things. More drawcalls = lower framerates for sure. One way to keep them down is make sure you are using the least amount of Materials, Textures, and Shadows as possible. As every one of theses counts against you. If you project can get away with no Shadows, perfect! That is in instant boost right there. If you need shadows, then you need to optimize your light sources and amount of objects that need to cast shadows. As I believe every shadow drawn counts as draw call. Finally on the topic of Materials and Textures. If you can manage to create 1 Texture that is Texture Mapped to all objects in your project that that would greatly reduce the number of draw calls. So if you have 10 Meshes that are all using the same Texture this will count at 1 Drawcall vs 10 Drawcalls. Hope this is helpful ๐
Ah also forgot to mention mesh combining. Let's say 1 of your gameobjects that is a Skinned Mesh consists of 5 separate meshes (usually this is an animating character), that will also count against you. Each mesh = 1 draw call. So if you can combine the mesh into 1, that means 1 draw call vs 5.
ok thanks for the suggestions
Use project showcase channels.
Batch count is more important, first optimize that, than do profiling and than look at tris
and I optimize that by reducing the material count in the scene?
Hi, i'm making a web app, and I want users to be able to create accounts on mobile, this implies typing in a textfield, but it doesn't work. HideMobileInput is unchecked, my canvas is configured properly, I tried on different browsers (chrome, firefox and safari), and it still doesn't want to open the keyboard. Would you know what's happening?
If i'm not mistaken Unity WebGL on Mobile is not fully supported. So this could be a related issue.
Might have better luck with something like https://github.com/kou-yeung/WebGLInput
hello friends, My webgl builds are not including a "streaming assets" folder. Does this happen to anyone else since updating to 2022.3.2?
thank you
Safari seems not to be enjoying it
It won't let me type in full screen
and that's the browser i'm aiming at
Do you mean non full screen does work? and only the full screen does not work?
just in case, "StreamingAssets" named exactly how it should right? not "streaming assets" or "streamingassets" ?
hiiii
can someone guide and help me on sending message through udp
in unity webgl
im sending message to a motor through arduino (in unity it works fine)
but in webgl it throws exception and doesnt wrork
@nocturne timber You might be running into the browser sandbox, which basically says that a browser can't interact with the host's filesystem. The unity editor is a desktop application and isn't sandboxed.
Talk to me more about how you have your project set up. Is your unity editor talking directly to your arduino, or is there an intermediary server that's handling the interaction?
its talking directly to arduino through arduino ip and port
using UnityEngine;
using UnityEngine.Video;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
using System;
using System.Collections;
using Sirilix.WatchoutController;
using Newtonsoft.Json;
using System.Collections.Generic;
using TMPro;
using System.Drawing;
using System.IO;
public class UDPListener : MonoBehaviour
{
// Listening port number
private const int listenPort = 5052;
// Listener variables
private UdpClient listener;
private IPEndPoint groupEP;
string targetIPAddress = "192.168.1.101";
int targetPort = 8888;
public void Start()
{
// Initialization of listeners and thread starting
listener = new UdpClient(listenPort);
groupEP = new IPEndPoint(IPAddress.Any, listenPort);
Thread thread = new Thread(StartListener);
thread.Start();
//SendUDPMessage("ZERO,1");
}
private void StartListener()
{
try
{
while (true)
{
byte[] bytes = listener.Receive(ref groupEP);
string receiveData = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
Debug.Log("Received message: " + receiveData);
}
}
catch (SocketException e)
{
Debug.LogError("SocketException: " + e.Message);
}
finally
{
listener.Close();
}
}
public void SendUDPMessage(string message)
{
UdpClient client = new UdpClient();
try
{
byte[] data = Encoding.ASCII.GetBytes(message);
client.Send(data, data.Length, targetIPAddress, targetPort);
Debug.Log("SENT" + message);
}
catch (Exception e)
{
Debug.LogError("Failed to send UDP message: " + e.Message);
}
finally
{
client.Close();
}
}
}```
What type of arduino is it?
arduino uno
Did they start putting linux servers in the arduino uno chips? A couple years ago you had to buy a model that was capable of interacting via ethernet. Weird.
Otherwise you talk to arduinos using serial comms
in unity it sends message (motor rotates)
in webgl it gives errors
I searched about it, webgl doesn't support udp I guess
That's not true -- websockets use UDP
C# has a libraries that lets you use websockets... But lets not get ahead of ourselves.
Let me re-read your code. I suspect you're writing to serial not to an IP address/port if you're using an uno.
Actually I'm just going to assume you're able to send a message over your network and arduino is able to do something with it (spin a motor).
Can you post the error you see in your browser?
I was going to say "your arduino is only accessible in your local network but not the public internet" but then I remembered if your computer you're using to access the webGL page is also on the same network then you'll be able to interact with local network resources.
https://store-usa.arduino.cc/products/uno-r4-wifi
Is this the uno you're using? It looks like it does actually have wifi capabilities built in. Nice
We have a project that is going great. We only have a problem with the audio.
Smart phone: check
Smartphone with wired headphones: Check
Smartphone with bluetooth headphones: no sound
Does anyone have any idea why this might be?
You cannot use raw sockets in webgl. The browser is responsible for building socket connections, so you have to use websockets. There are demos you can check how to build it via unmanaged javascript https://github.com/jirihybek/unity-websocket-webgl
audio channels?
thank you for your reply. Here is my assets folder inside of unity. Are you saying that there should be a folder called "StreamingAssets"?
Yes
I thought that unity just packed everything up and made the folder* "StreamingAssets" during the webgl build
Should I change that folder name from "Assets" to "StreamingAssets"?
Automaticly created folder is Build but streaming assets actually requires folder named that way
do not change Assets to streaming assets.
All build needed files will be added into Build folder. Streaming assets is something you manually can add stuff that in most cases is somehow dynamic. . Just create new folder and all be good.
https://docs.unity3d.com/2019.4/Documentation/Manual/StreamingAssets.html
abit more about it. with some packages it is created automaticly it seems.
thank you.
last Q
Should the "StreamingAssets" folder be inside or outside of the "Assets" folder?
Yes it should.
Another tip, if you will accesing files from streaming assets, please check the link I send as many people ignores this line:
To read streaming Assets on platforms like Android and WebGL , where you cannot access streaming Asset files directly, use UnityWebRequest. For an example, see Application.streamingAssetsPath.
Is there a way to "profile" a website? My unity webapp is running at 180fps when hosted on local browser and on itch.io but on my target website it barely goes at 60 frames, at this point I guess its an issue of the website running to many stuff in the background since it embeds the webapp and also do other stuff in the same page. is it possible or there could be other issues?
Yes, when you're in full screen and you click on textfield, it takes you out of full screen and the keyboard appears, that is the only way i've made it work
hi
everyhing was working fine
all of a sudden I cant build anymore
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002bf] in <7105be432fb64891b07085914e6cd5c1>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <7105be432fb64891b07085914e6cd5c1>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr)```
so i removed my udp lisstener script and it built thats so strange
I am pretty sure WebGL does not support udp and only works with websockets
Hey I am trying to compress my sprites for a 2d game for webGL and I have reduce max size of image from 2048 to 512 but it show little to no change in build and build report...am I missing something?
this is my script
Do the sprites have larger resolution?
That size isn't referring to file size directly
Yes they have(eg one is 1920*1080)...although when I reduce the image to 512 it show size decreased in inspector but not build report
Check the quality settings, and modify the entry there for webgl. I'd also expect very little change (~50kb a sprite). That's more-so to reduce ram and gpu usage imo
Sry, please give me a hint? ๐ โ๏ธ
Oh basing this off an issue I had the other day. We had a some weird issue making a call with our audio channels where a wireless headset had some driver software that caused it to attempt to access an audio channel that didn't exist.
Is it possible to change the full screen button image?
I can try literally replacing the image in the build but I'm worried something might break and I also don't want to have to do that for every webgl build I make for every update
You can create your own template to avoid having to make those changes afterwards https://docs.unity3d.com/Manual/webgl-templates.html
What your error logs says?
i fixed it
unity webgl doesnt allow netwonsoft.json
I removed my netwonsoft.json and just used JsonUtility
it built
I'm using the profiler (in editor) and I get a big chunk of resorces on "Other", can somebody help me figure out what that is due to?
Moral of the story dont profile on Editor. You will get tons of fake red flags and miss actual problems. others can be easily editor stuff.
it is a bit easier to see things when you select. at least for me as you can sort by usage. But once again, i would ignore other until same result would be on profiler when profiling webgl build.
ok
It should work fine. Make sure to use Unity's package for it.
Where can I find it?
Package manager?
is this from local host right? It should connect. If it is not local you might need to enable browser to allow stuff over http. Chrome dont like that too much.
try running : Build And Run. it almost always works well
The package might be hidden, but yea
okay thanks
I tried both on local chrome and on itch.io
and I remember that few months ago that worked ๐
what does build and run does on webgl?
It automaticly host temporary webserver for you. build your webgl and starts it locally. Just it setuped in away stuff works more often ๐
ok I'll try thanks
it worked
here's a part
I have no idea on how to read that and what are the important parts, can somebody please help?
This is by using deep profiler, the situation seems really different
i've built my project on 2 different devices, and one works fine. The other stops and shows the error : call_indirect to a null table entry
Hey everyone, I have an empty GameObject that acts as my GameplayManager. At the top I have the following public static GameplayManager Instance { get; private set; }
I use GameplayManager.Instance.[fields] to access certain methods and variables.
However, when a game ends and you restart it doesn't work as variables pickup where it left off the last game. I tried resetting them to their default values when the game ends but listeners and events still break. I also can't seem to destroy the object as it messes up elsewhere (mostly since it is a network object that syncs users).
Does anyone have an idea how I can reset "Instance"? Thanks!
how do you detect if on mobile phone or not?
Nope, I only have one scene
if you reload the scene with SceneManager.LoadScene(0) if would reset everything
Oh interesting. Okay thanks I'll try that out!
Hey guys, Iโm trying to find the recommended server specs for running a 3d unity webgl build, but I canโt find it anywhere
Can someone point me in the right direction?
I would greatly appreciate it ๐
Are you talking about something other than HTTP servers serving those builds?
System requirements for an actual game scale with the content, just like on other platforms.
If you're just talking about a webserver that provides clients with a webgl build, specs can be low since there's very little cpu usage to serve that up. Best to have fast storage
Digital Ocean has been my go to for a long time, they now have this cool app service. It syncs with your Git Repo and builds your front-end automatically on every push / update. It's free to start and even includes CDN. First paid tier is only $5 https://www.digitalocean.com/pricing/app-platform
I'm using Cloudflare today though to serve my WebGL clients. After some research and doing some performance + price + support level comparisons between Cloudflare, Firebase Hosting and Digital Ocean. Cloudflare won for me.
Hi everyone, I am having some issues with our game, using textmeshpro on chrome when you resize the window the tmp text completely dissapears, everything else looks fine so it doesn't seem to be a layouting issue.
I saw some other user reporting this on the unity forum and added the info for our case, does anyone have any idea what this could be? On pc builds this doesn't happen at all.
this is the thread with more info, and a video showing the issue
maybe you want first do what it says? open console of browser (f12) and see what it says on console.
This error can have multiple reasons. Most common that you run out of memory. More rare similar one is when you try access array element which does not exist
anyone encountered this error before when building webgl? apparently my game runs fine pre build but after i build the game, the game does not run
do you have any conditional formating? have you tried removing and adding the compoment again?
Gonna redo a fresh project and see if i can proc that error again
I need some help regarding compatibility for webGL
I toggled AutoGraphics API but I couldn't run on an old laptop, I tought that was the setting to adapts the graphics to each hardware, is it wrong?
Then after that I set manually the graphics to WebGL1 and it worked
Now if I include both WebGL 1 and 2 will the software automatically manage that compatibility problem?
New unity version officially do not support WebGL 1, Only webgl 2.0. It might be not only laptop problem but more the browser version on that laptop. as at least I do not know that situations where webgl 1 runs better than webgl 2.
It doesnt run better, it just runs
On older laptop webgl 2 is not supported
So I want to make a nerfed version for older laptops
have you tried updating browser on those laptops?
yes, fully updated
How old of a laptop we are talking about? As webgl2.0 is pretty much browser based... Very weird
an dwaht browser you were using?
https://www.khronos.org/webgl/wiki/Implementations/Firefox
Well it seems on super old ones your drivers might block it.
I personally would throw away webgl 1 users, as amount of them will be super small and because of them all other users will suffer.
But if you insist, then
https://docs.unity3d.com/2021.3/Documentation/Manual/webgl-graphics.html
Automatic Graphics API should automaticly select correct WebGL version, but you need to manually add both in the list.
You can check SystemInfo.graphicsDeviceType to console out what support the latpot have to make sure it select correectly.
Got it thanks
I tried SystemInfo.graphicsDeviceType on a WebGL build and I got "OpenGLES3"
I expected the graphics api name
Also SystemInfo.graphicsDeviceName returns "ANGLE (Intel, Intel(R) UHD Graphics Direct3D11 vs_5_0 ps_5_0, D3D11)" so does that mean it doesnt use the gpu? I have a 3070
ok i have build again from fresh project now i get this error
hello
hey guys how can I host my own webgl game on my own website lol
i think you have to make an iframe with the index file
nvm I think I figured it out
I will try my way rq
my idea failed lol
Copying the file structure bit by bit is what a pro would do
I aint no pro though
there are pretty straightforward tutorials on how to do this using the React-Unity-Component
This guy has done a ton of work building this, consider cashapping him a dollar
ima search online for yt tutorials now with this info thanks
uh this says that its react tutorial
and there was only 2 tutorials doing the same 1 method that I cant use lol
import React from "react";
scratches head
https://www.youtube.com/watch?v=_L9xwZFqcMk
talking about this channels tutorials first 2 and only 2 that popped up
Plus I'm kind of using a host website not myself hosting so I can't do it the same either way lol
Nothing wrong with using github or replit or something else
edited
I got 1 person to help me in 2 hours with $1 incentive it would take forever so I doubled it so in theory it should now take half the time
Could any one give me suggestion how to reduce memory blueprint on webgl project. Problem is that there is a lot of images downloaded via runtime and displayed in preview. Even with correct compression for the platform it still take quite a lot of memory all the time. And I keep hitting memory cap on iPhones (around 300mb it start dying. browser should be able to handle 500 mb, so my guess 200 goes for browser it self and then ~300 left for webgl.)
Tried even compressing them to correct format and not png or jpg before downloading. After downloading and added as sprite the png file it self is discarded. Any ideas would be helpfull
hello everyone, i have a problem. how to show render texture on webgl?
huh? what do you mean? Same as in other platforms?
no, it don't work like other platforms. It don't show anything on screen :v
i don't know why and how to fix that
this how it work on other platforms with simple texture streaming. you render to texture from camera and it does work.
More common problem if you put that texture on UI or something, canvas not always register that texture changed, and stays black screen. That can be solved with refreshing UI, disabling enabling element or setiing UI dirty.
ah ah, i put it on the UI
So most likely it is more UI problem than webgl. You just notice on webgl, as it is considerably slower so timing might be different on when first canvas update is called and checked if UI is used or not.\
okay thanks
So on editor you dont have this but only on webgl? Does your editor have ANY red errors? regardless if it works or not?
How heavy is your application on Memory aspect?
Are you using some webgl not supported features like: threading/tasks or VFX graphs?
no
my application has some sprites
then 3d glasses models
i use webcam to do face tracking and place those glasses models on the face
then theres options for taking pictures and sending email too
are you using webcam plugin of any kind? as I remember webgl webcameras is some tricky stuff.
https://docs.unity3d.com/Manual/webgl-browser-access-device.html
Does it crash on load or does it crash on specific event?
im using zappar
for face tracking
it is
i use a keyboard plugin that then can be used on touch screen
To make HTML elements receive a keyboard input, set WebGLInput.captureAllKeyboardInput to false. This way, the application receives input only if the WebGL canvas has focus.
If it does not work only for webgl most likely either your canvas dont have focus or your webgl input was disabled. Also make sure it set to run in background to ON
https://docs.unity3d.com/Manual/webgl-browser-access-device.html check if that device is visible in unity by debuging list of devices first. You might need some workarounds. I was using js for webcam to work corectly. But there can be so many problems that can cause it. Maybe you just run out of memory when trying to track 4k image or something.
well that was quick. lucky find!
Any help on this?
how can I host a webgl game on my website
U MAKE A DIV OUT OF YOUR GAME
go to the location of your unity webgl build, then you open index.html, now you add the elemts of your website or your website in general there
it works
In principle this -- but instead of applying to the build artifacts after a build, you can create your own WebGL Template by following the "Add a WebGL Template" section of this page in the docs: https://docs.unity3d.com/Manual/webgl-templates.html
That way you don't have to remember to apply changes after a build since you can just add the desired changes to the template and build your webGL player onto that.
That's definitely the right answer :D. Also keep in mind the templates do change depending on your Unity version, so if you upgrade your project later you may need to revisit the template
Could anyone guide me to understanding while i have this behavior . First image is editor memory profiling, and second is webgl build. The size of shader usage have quite weird difference. Reducing reference count should be one way of optimizing, but I think the size is still too big for shader and its variants. any ideas that could guide me to optimizing?
If you want to embed a webgl game within an existing webpage it may be easier to use the react component though--plus you can do you html and css changes to make the content surrounding the game more than just a white blank page ๐
will WebGL1 be removed from unity?
So from 2023.1 ok
I wonder if there is a way to force webgl2 on old hardware
Cause as far as I understood its just the browser rejecting to run it when the pc specs are too old
there is no way to force things that they dont have. Its like forcing them to update their drivers or buying new pc. Best you can do is to have nice HTML alert that you are sorry that this website does not support your device. Please use something newer and a link to good pc setup ๐
Or you can try creating streaming service, which will actually render you stuff somewhere and then just deploy video, cloud webgl if you must. It will work on almost all devices. Is it realistic? no not rly, but sounds good ๐
Yeah not really realistic if the user count is high
Ok then, I just need to know when the user pc can't handle webgl2
The problem if you need that low end users to be included, try checking Three.js or other more browser native approaches.
what are them? alternatives of webgl graphics?
Alternative to Unity and Webgl. Three.js, playCanvas kinda, and there some more that is 3D graphics on browsers. They have better performance and lower requirements. And most likely less limitations. However there is price, it is not Unity.
Could anyone guide me to understanding while we are developing vr applications and at that time i want to create a site using webgl also.
but i used the oculus intigration and XR Integration so that reason i can't abel to work on webGL.
so how i can create a multi-device application, which app user can run in oculus, Laptop or Desktop, and as well as in browser.
https://assetstore.unity.com/packages/tools/integration/webxr-exporter-109152
Have in mind this is 3 years old information. When you making webgl, you dont really make multi platform stuff, webgl is like it own platform with many limitations. Maybe there is better approaches these days how to implement it on webgl. As at that time Oculus intergration kits or XR integration kits was not aime at webgl at all so they did not rly worked. Now it might be easier, sorry all I can do is this.
Maybe @charred briar could give you more new information.
@charred briar please can you give more information on it ?
but when we using the web XR, at that time photon server can be suported or not. reason of in my last project we can't abel to use photon server for webXR project. that did not run perfectly.
WebGL supports only WebSockets. Photon should have support for it. But if you want connect to mobile devices or PC you will nee method to use multiple transports. Mirror Using multiplex for that, I would think photon should have something similar.
While youโre right about there not really being many XR games based in webGL today I would politely advise you not to discourage the idea in others.
WebGPU is a bit of a game changer for web based products because it will allow comparable performance to โnativeโ applications.
Iโve only toyed around with webXR (the concept, not the asset) by creating a toy tower defense game (except you can pick up and throw the minions). I had to be spartan on the graphics side but I was happy I had a XR game experience going through my web browser.
webgGL build: I have a video with sound file playing and the sound is set to 3d. After the build the sound is 2d. Any idea how this is happening? Attched are my audio settings.
thank you as always everyone here is amazing.
video setting for reference
In my build settings i noticed that "spatializer plugin" is none. Could that be it?
Thanks for the shout out! Yeah WebXR through unity has been.. mmm very very interesting.
I haven't tried in a few months, but ran about a dozen different framework tests and builds. There are some compelling things for sure--- but we ended up just using raw webgl frameworks and removing unity for our webxr stuff. It was just too unpredictable with unity in the mix, especially for cross browser support...
But yeah, we definitely use photon with webgl in non-vr contexts!
They have some samples on their site for it.
But yeah, definitely take a day and play with the webxr exporters you can find in the assetstore for both AR and VR. Some are just repacking a scene to kinda work in threes.js, but others do interesting things. I absolutely wish I had a free day to dig into it more. I feel like there is a success path there. We did have an experimental plugin we tossed together for a while - but I removed it from our templates internally just cuz we couldn't get time to maintain it. And we built it either some commercial plugins that stopped us from going open-source with it ๐ฆ
Also, I found other interesting projects just digging through public github
Thank you for your opinion. While it was not the intention to discourage other people, rather to inform them that currently webgl is not the best place for VR. As person who loves VR i know how much performance effects the experience, how much even a little frame drop can cause nausea for a lot of people. And I want people to experience best VR experiences. And as developer I know how WebGL makes optimisations so so so much harder, like if you want to have 72 fps (for 72HZ devices) on webgl you will need at least 216fps on PC build and stable at that. So if it is first VR project WebGL is really not the best place for it.
I too wait for WebGPU, and from what saw in forums there are already kinda working version of it for unity, but even Unity devs said it will take long time until it will be as smooth as webgl2, and then more time to overcome it. So I am excited but at the same.. well doubtful on immediate effect. And if we talk about phones and WebGPU, apple will take their sweeeeeet time to enable that feature on their devices, same as it was with webgl 2.0
Itโs so wild that one can distribute a VR experience over the web. Building VR experiences definitively requires that one knows how to properly allocate a performance budget. If that person has never profiled a webGL game then they arenโt ready yet to tackle the resource starved platform that is a distributed web VR experience.
Unity devs are hopefully busy at work getting Unity ready to run on we GPU. Iโm bias ofc because I love distributing my games over the web.
Iโd like to return to my web VR experience one day and make it better. We do exist even though itโs a rare person to want to build such a thing ^_^
can i have an AR webgl made in unity? when i build i have a black screen and no camera..
Which plugin are you using?
And yes, we do lots of WebAR, you just can't use things like ARFoundation ๐
But its a lot easier to not go through Unity for WebAR
imho
Hello, beginner here. This question is way over my head, but it keeps bugging me. When I build an empty project into game, it uses a lot of resources when playing it. I figured out Application.targetFrameRate changes that. So, how do I tell the Unity game to behave more like Windows Notepad? Show something on the screen and not update until user input or event. For example, if I am making a little text-based webgl game, simple visual novel, how do I make sure Unity WebGl game will use as little CPU power as possible? To save battery or to give time the device to cool while the player is reading. Do I manually set Application.targetFrameRate to zero until some event fire or something?
I am not sure how to search for this in English. When I try Google is always telling me about code optimization and to not run this or that in update. But this is not what I am trying to ask.
I would look into how https://docs.unity3d.com/Packages/com.unity.adaptiveperformance@5.0/manual/index.html is handling it. You can probably find resources on how to catch inputs with new and old input system.
We did this a long time ago, I think we did it by suspending the process on the webside. https://pixeleuphoria.com/blog/index.php/2020/04/15/unity-webgl-suspend-app/
Learn how to completly freeze (not just throttle) your Unity WebGL apps with JavaScript commands. Includes embedded interactive sample.
For that client we paused it until the user clicked on something, it was a huge help.
We also were generating a screenshot on right click for menu overlays etc and sending it the web end as json. Might be an option as well to show just an image.
That was back in Unity 4/5 though. So there may be better ways nowadays.
Thanks!
Is there a way to Trigger a specific Szene via Link?
For example:
Index.html#scene2 -> to force the WebGL starting with scene 2 than the mainScene?
I got this error on my webGL build and I can't find any discussion where someone is experiencing the same error. In the build folder the file is there. What might be causing this?
You can pass info between the html elements and unity using messaging. In unity you can also get the applications URL. So using a URL query should be fine. We use it for our webgl multplayer room links
What happens when you try to go to that file using the URL in the browser?
I.e. if the site is
https://jimbeans.com/game
you should be able to access
https://jimbeans.com/game/Builds/Builds.framework.js
Is there a limit to WebGL builds? My project is pretty hefty now (9g) and im afraid of building it.
In theory no, but who wants to download 9 gb every time they play the game
Project size doesn't directly translate to build size. Projects often have unused assets and assets in formats that are much larger than the final asset.
how come whenever i build my unity game to webgl and put it on itch.io the actual camera view just goes completely black, the quality level is at its lowest and every material has full emission
Probably because you used shaders that require deferred rendering, and it is using a lower quality setting from the Settings panel, which probably is changing to forward rendeting only and reducing the quality all around
Is there a way to debug WebGL build so that I can see on which line error happens?
Anyone tried Unity 2023 with webgl build? I tried profiling same project, but the memory usage for 2023 is 100mb+ bigger than 2022. I want to confirm it is really the case.
Mostly worrying thing is Native part, as there is no way to handle it normally.
A - 2023 Build
B - 2022 Build
Hi ! We have a game with some video content. We build a custom video manager around the Unity video player. Recently we have update to Unity 2022 from Unity 2019. Since then, it seems that the video player is having problems with WebGL, especially when I'm using Bluetooth headsets: video freezing and/or sound speed up. Has anyone experienced this kind of problem before?
I'm trying to run my webgl game on local browser but I get these errors:
"Uncaught RuntimeError: null function or function signature mismatch"
"Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development."
If you're getting a cross-origin error then you're likely not running a local webserver https://unity.huh.how/web/common-errors/cross-origin-requests
What does this settings actually does? I read on the unity documentation that turning it off will increase performances.
In short it reduces logs and information you get from your project. It increases performance as you don't need to have information about what happening in the game. But it is negative when you have error and there is no way to learn what kind of error it is.
But maybe someone can give better answer
So with none, in case of error I guess it kinda provides no infos, got it
@astral wave And more importantly, the game will crash.
w/ or w/o them?
Without exception support
https://blog.unity.com/news/plan-pricing-and-packaging-updates
So how the install thing will work for webgl?
Q: Does this affect WebGL and streamed games?
A: Games on all platforms are eligible for the fee but will only incur costs if both the install and revenue thresholds are crossed. Installs - which involves initialization of the runtime on a client device - are counted on all platforms the same way (WebGL and streaming included).
This no way explains how it wil be working exactly?
I've been trying to figure this out too.
Right now, WebGL games store data in PlayerPrefs and cache the game in the browser's IndexDB. If the player / player's browser clears data when closing the window/tab, that data goes away. So if they play again, they will be seen as a new install?
And when publishing to platforms like Itch.io, every new version is at a different path within their domain and so the PlayerPrefs data and other stuff is not carried over, so each new version of a game will be seen as a new install?
Does anyone know how the new pricing impacts web players? Something I'm a little confused by is "what if I use a CDN" to distribute my unity web player.
From a technology perspective seems like the "install" (and thus the install tax) would happen when a CDN cache server saves the file. If a user pulls from the CDN cache, that action seems like it shouldn't count as an install. But it probably won't work this way.
Again from a technology perspective for web players if the player navigates to a web page using a browser that contains the game then game is cached locally in the browser. If the player reloads the page is that another installation?
Another question -- does the web player installation count per device or no? E.g. if I open my web player in Chrome, Firefox, and Opera is that 3 installations or 1?
What if my WebGL build is LAN based only? No devices talk out to the internet
I have some guesses for some of the webgl applicable changes.
Q: How are you going to collect installs?
A: Probably a registry value and then sending that info to a Unity server when online.
Q: Is software made in unity going to be calling home to unity whenever it's ran, even for enterprice licenses?
A: Yes. When it has an internet connection it will try to phone home. While it isn't connected it will just update the registry value.
Q: Does this affect WebGL and streamed games?
A: Every time your browser refreshes a WebGL game it counts as an install. If a botnet were to connect to your WebGL page you would get financially ruined in fees.
Oh yea good point.
Surfing on that point, what if the โgameโ is actually an internal tool only used in an intranet. Do those installs count?
I fear your answers might be true.
Malicious actors could botnet a unity web player page and screw the developer out of their lifetime installs/ruin them financially.
If youโre planning on using Unity you 100% are going to want to LLC so if you do get screwed over it just bankrupts the LLC.
Q: Does this affect WebGL and streamed games?
A: No, the Unity Runtime fee does not apply to WebGL games.
(Updated, Sep 13)
https://forum.unity.com/threads/unity-plan-pricing-and-packaging-updates.1482750/
General discussion should still continue on #archived-pricing-updates-talk
hello, i want to show keyboard on webgl mobile? How to do that?
https://github.com/kou-yeung/WebGLInput use this asset if you need keyboard for input. It will show webKeyboard.
thank u
My canvas is pushed up when the keyboard is shown. How do I make it overwrite the current ui?
this is CSS and html stuff I think.this pluggin simply creates InputField on top of your input on webgl. You will need to update that part yourself depending on the project.
Hey ,
i have created a unity application witch hits the API using UnityWebRequest now in that request i need to send a token X-CSRF-TOKEN which i get as a response Header of my previous hit
Can anyone help
Anyone know how to get it fixed ?
UnityWebRequests work just like any other request/response library or tool (like curl)*. Which is to say that if you can figure out how to do the request/response/request/... sequence using something like Postman (GUI) or curl then you'll have the fundamentals to know how to do it in UnityWebRequest.
in that request i need to send a token X-CSRF-TOKEN which i get as a response Header of my previous hit
You need to extract the X-CSRF-TOKEN value from the first request. You can do that using the UnityWebRequest.GetResponseHeaders().TryGetValue("X-CSRF-TOKEN", out csrfToken) api.
Here's some sample code:
using (UnityWebRequest request = UnityWebRequest.Get(BASE_URL + "/auth"))
{
yield return request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogError("Error fetching CSRF token: " + request.error);
yield break;
}
// Extract CSRF token from the response headers
string csrfToken = "";
if (request.GetResponseHeaders().TryGetValue("X-CSRF-TOKEN", out csrfToken))
// 2. Send another request to '/pets' with the CSRF token
using (UnityWebRequest petRequest = UnityWebRequest.Get(BASE_URL + "/pets"))
{
petRequest.SetRequestHeader(CSRF_HEADER, csrfToken);
yield return petRequest.SendWebRequest();
if (petRequest.result == UnityWebRequest.Result.Success)
Debug.Log("Received response from /pets: " + petRequest.downloadHandler.text);
else
Debug.LogError("Error fetching /pets: " + petRequest.error);
}
else
Debug.LogError("Failed to extract CSRF token from /auth response headers.");
}
}
*Except where it's different.
thanks for the code Example i implemented the Same
And Sorry if my Question was not clear enough But
the Problem is That this code will work but in
WebGl Build it wont wont be able to Access the Set-Cookie Header because of Browser Security
so I wont be Getting the Access of that Header
There is restrictions for that header for the front end.
Yes that is the problem there as browser won't allow so I got a way around by accessing the cookie using document.cookie in js function which I can call from unity and have the token
webgl is kinda redundant, can we have WEBGPU?
it's like a really strong version of WEBGL, this would revolutionize web gaming forever
we could clutch this engine in the future
this might be against the rule but, please add the WEBGPU Support for the engine ๐ ๐ญ
Has anyone uploaded their game to any websites like crazygames.com with ads integrated
I have some questions
WebGPU is in progress https://unity.com/roadmap/unity-platform/platforms
still waiting for multithreading ๐
Well actually ๐ค , you can use c++ multithreading 
that was a joke
it will come sooner or later. But My guess it is years until it will stick. I mean Apple with Safari alone will be HUGE BRAKE on this topic. I mean how long it took them to took webgl 2.0 into safari ๐
soooo later
I have a Unity WebGL exportet game running, and for me personally it works on like 15 devices, but a friend of mine, who unfortunately lives too far away for me to test the devices personally always keeps running into the same error after he plays like 5-8 levels(See below). I have all the Player Settings on default. I can not really narrow it down to a specific LOC, because I can not reproduce the error, any ideas on why that could be happening? I use Unity 2022.3.9f1
Auf flutter-crush-4ece9.web.app wird Folgendes angezeigt:
RuntimeError: memory access out of bounds
at wasm://wasm/074760d6:wasm-function[71139]:0x184eec1
at wasm://wasm/074760d6:wasm-function[71123]:0x184c87e
at wasm://wasm/074760d6:wasm-function[72385]:0x18e9ff1
at wasm://wasm/074760d6:wasm-function[72382]:0x18e911b
at wasm://wasm/074760d6:wasm-function[75998]:0x19b4c0a
at wasm://wasm/074760d6:wasm-function[76003]:0x19b9a6a
at Module._main (blob:https:// flutter-crush-4ece9.web.app/045de033
-15be-4559-81ac-d3aa9e1b0afe:10:323965)
at callMain (blob:https:// flutter-crush-4ece9.web.app/045de033-15be
-4559-81ac-d3aa9e1b0afe:10:403838)
at doRun (blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559
-81ac-d3aa9e1b0afe:10:404285)
at run (blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559
-81ac-d3aa9e1b0afe:10:404457)
at runCaller (blob:https:// flutter-crush-4ece9.web.app/045de033-15be
-4559-81ac-d3aa9e1b0afe:10:403497)
at wasm.//wasm/074760gb.was-function[/2385.0x82911
at wasm://wasm/074760d6:wasm-function[72382]:0x18e911b
at wasm://wasm/074760d6:wasm-function[75998]:0x19b4c0a
at wasm://wasm/074760d6:wasm-function[76003]:0x19b9a6a
at Module._main (blob:https:// flutter-crush-4ece9.web.app/045de033
-15be-4559-81ac-d3aa9e1b0afe:10:323965)
at callMain (blob:https:// flutter-crush-4ece9.web.app/045de033-15be
-4559-81ac-d3aa9e1b0afe:10:403838)
at doRun (blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559
-81ac-d3aa9e1b0afe:10:404285)
at run (blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559
-81ac-d3aa9e1b0afe:10:404457)
at runCaller (blob:https:// flutter-crush-4ece9.web.app/045de033-15be
4559-81ac-d3aa9e1b0afe:10:403497)
at Object.removeRunDependency (blob:https:// flutter-crush-4ece9.web
app/045de033-15be-4559-81ac-d3aa9e1b0afe:10:17032)
at blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559-81ac
d3aa9e1b0afe:10:1913
at doCallback (blob:https:// flutter-crush-4ece9.web.app/045de033-15be
4559-81ac-d3aa9e1b0afe:10:102753)
at done (blob:https:// flutter-crush-4ece9.web.app/045de033-15be-4559
-81ac-...
If it is of any help, i created a simple Match 3 game, so nothing special, just a 2D game. They use a Galaxy Tab S6 lite for testing
Sounds like it ran out of ram.
yes, but how can that be? I checked in my browser on my phone and on my PC it uses around 300-400MB of Ram, the Galaxy Tab S6 lite has 4GB
Could be a memory leak over time?
Or they opened a bunch of stuff in the background
Or other tabs are active
I'm not sure WebGL is supported on mobile yet
4gb memory is device memory. Most mobile browsers have their own memory limit. For example iphone x limit is like 350 mb ram. At 400 it crashes. Newer devices have higher limits but anything over 500 is a dead sentence
also another problem with webgl and mobiles is your teture formating. PC likes DXT format but phones cant handle that and needs ETC or ASTC. So if you build your build with DXT, on mobiles all textures will be decompressed to RGBA and that will increase your memory usages 4 times ^^
memory on mobile webgl is such a pain ๐
How do i change the formating from DXT to ETC or ASTC? Nevermind, found it
What would you say is better, ETC2 or ASTC? The app will be used on mobile browsers like 95% of the time, so i care more about mobile browsers than PC. Or is it good to have a combo build like this: https://docs.unity3d.com/2022.1/Documentation/Manual/webgl-building.html#desktop+mobile
Wow that is crazy, the ram usage dropped from 300 to 150MB, when using ETC2, you may have just saved my master thesis, thank you very much!
Here are all my "other settings"
No problems. ETC2 is older and supported on more devices. ASTC is newer and some devices dont support it. But it is easier to find ASTC converted than ETC2, for example if you want download some images and dont use CPU to compress them on run time (tho from my tests it is not worth downloading already compressed images). So I would recomend ETC2 in most cases. https://docs.unity3d.com/Manual/class-TextureImporterOverride.html
I think new iPhones supports ETC2, but this table states it doesn't. Forgot how it really is sorry. We are using ASTC, but for different reason.
Thank you very much for that information, that is really helpful
I will just try both formats, first ETC2, and let him test the app if it does not work i will try ASTC, maybe it works.
Any fix for this error in webgl?
You can't run WebGL games directly from the file system. If you want to run them locally you have to do "build & run" in the editor or set up your own local server
You can also run the simplewebserver with cmd if you can find the file path for it if you already built and don't want to do it again
thank you! I didn't know that before.
Hey guys! Is it possible to host a Webgl game using docker?
Yes, just like any other static website
It's literally just static files. You can host it with whatever serves static files.
The only gotcha is that if you compile the project with file compression, the server must be able to handle that compression format
Here is a small example for a Unity WebGL Game in Docker https://dev.to/tomowatt/running-an-unity-webgl-game-within-docker-5039
is targeting webgl build in unity worth pursuing atm? is there a minimum phone spec requirements for it to run at an ok framerate? (i'm working on a top down multiplayer 2D shooter and want to target mobile browser for multiple reasons)
i tried phaserjs and cocos creator and they're pretty fast, but i'd really prefer to use unity if the end result can be just as fast or close. some examples i tried will crash my phone browser but that might be because they're build on older versions ๐ค
From my experience unity webGL isn't ideal for mobile devices, so it won't surprise me if it is slow on quite a lot of older devices. And as AdionN mentioned here: #๐โweb message
You could easily run into memory problems if you are not very careful about it, because mobile browseres sometimes only are allowed to use 400> MB of RAM
do you know if thats per tab or the browser app
The only thing i found out is that answer from 2022, which states that iOS Safari limit is 384 MB on version 15 https://stackoverflow.com/questions/74506298/how-much-the-memory-limitation-is-on-the-ios-device-browser
And i do not think there are any official documents as one comment says "Unfortunately there isn't any official document on the internet and the numbers are experimental that are calculated by developers. "
ah , thanks .. i'm working on the first couple of scenes on unity and cocos creator at the same time to visually see how well they run but tomorrow i'm gonna research as much as i can about optimizing for webgl in unity because i'm sick of writing javascript and alot of the stuff i have to do in cocos is already in my assets packages in Unity ๐
Personally i use the Flutter Unity widget(https://pub.dev/packages/flutter_unity_widget), which basically adds the webgl as an iFrame into the flutter application and allows me to add my game in to a Flutter Application which makes it possible to create an iOS/Android and Web App at the same time, while only coding it once. Maybe this helps
Not sure who to ask, but does unity's authentication work with webgl?
We added the package/set up simple anon sign in, but not getting any call backs and noticed that the package doesn't explicitly say it works for webgl
if it relies on system.threading somewhere to do an async call then probably not. You'd have to override async threads to be coroutines (Unitask style)
I have a js library function that im calling from c# and giving it a string but in js it seems to be automatically converting it to int i guess because js isn't typed. any idea how i can fix this?
top one is what C# sends bottom is what js ends up with
nvm figured it out, I needed to run the UTF8ToString() function on it because the number is a pointer
Hi, I have a server in node js.
And I have created a an API which will server the webgl build's : index.html file on that url.
But the issue is that the index file is unable to access the build data and template data(generated with the build)
So how do I serve the build file so that the game actually renders, right now it's just showing me a text : TEST WEBGL, and no game canvas is being rendered.
well you have to make the API serve all files in the build, not just index.html
Here's the snippet :
// Serve the Unity WebGL game by _id
app.get("/api/playGame/:id", async (req, res) => {
try {
const gameId = req.params.id;
const folderPath = path.join(__dirname, "Games", gameId, "Builds"); // Include "Builds" subfolder
// Check if the folder exists
const folderExists = await fs.promises.stat(folderPath).catch(() => false);
if (!folderExists) {
return res.status(404).json({ error: "Game folder not found." });
}
// Serve the index.html file from within the "Builds" subfolder
console.log("Folder : ",folderPath)
res.sendFile(path.join(folderPath, "index.html"));
} catch (error) {
console.error("Error:", error);
res.status(500).json({ error: "Internal Server Error" });
}
});
How do I do that?
You'll have to change your URL structure a bit. You can't have it serve the index file from that URL. It won't be able to load the other files from that.
It could be something like /api/game/:id/play and /api/game/:id/:file serves the other files
So, when user access /play API, I should call :id/:file API within that API?
You need two endpoints, one that serves the index and the other that serves all the other files
Or just one endpoint that serves everything in the directory
Ok, makes sense.
So it's like, I will serve the whole build folder then the Server will find the index.html and serve it with all the build files
Isnt it?
Yes, but you might need to specify that it serves index.html if no other file is specified
If you google for "serve entire directory in nodejs express" it'll explain it
ok, thanks man.
I appreciate your time ๐
where can I post jobs?
!collab
We do not accept job or collab posts on discord.
Please use the forums:
โข Commercial Job Seeking
โข Commercial Job Offering
โข Non Commercial Collaboration
hello, i have a question
sometime my audio in webgl don't work on ios device
How do I fix it?
Anyone any idea, what that error could be? I unfortunatelly do not have access to the device, so i can not debug it. It is a Samsung Galaxy A40 device, where the game is played on
Any good fixes for the weird z fighting webgl gets that don't show up in editor or standalone? Can't really change the model for a lot of cases I'm getting for stuff that actually just needs small details like faces and junk.
Pics of what youโre seeing?
its your typical Z fighting, on standalones you see it when you have two planes in the same spot but for webgl it happens if stuff is just close together it seems
from what ive seen online it seems to be a common issue something about chrome having a small z buffer
Push your camera near plane out a little bit. You probably donโt need the default 0.1M.
The rounding for Z is tighter on webgl. The fix is to increase the Z distance
Or delete one set of faces
Neither of those are really much of an option for things like the eyeballs, and may or may not be doable for the clothing :/
Ah. Well. In that case, when I were a lad we had tโ ordering table and floating point z buffers were a distant dream. Use renderqueues or passes to handle your own pseudo sort, and good luck.
Well, you know the limits. No idea how your models are setup or why. I'm not even sure from the photos what's being highlighted as the problem - so not sure if it is even a Z issue. But it's with you now to figure out and resolve:)
So videos can't be played from the assets folder in WebGL. What's the best workaround for this?
streamable assets?
you'll have to make sure the path is there and has the assets you want in it https://docs.unity3d.com/Manual/StreamingAssets.html
Has anyone had issues with very bad artifacting when playing webgl builds on mac? I've tried 100 things to fix it but have had no luck
compression settings, depth priming mode disabled, different versions of unity (now on 2023.2.0b11), different urp settings, etc
Ya I already knew the limits and said it was a z issue so that's not very helpful
Seems kinda stupid that they could make a whole 3d render system in webgl but couldn't manage a floating point for the z buffer idk that's just a weird limit to have.
I'm confused, what did you expect us to do about it? If you knew it was a Z-rendering limit, which I'm still not convinced it is from your cryptic photos, then you know what the options are. Don't render two faces close to eachother, or override one of the renders. If you know that... why are we having this discussion?
I'm assuming you mean as-in image compression? I've had to really fiddle with the WebGL quality settings in the Project Settings pane before. But some platforms have some pretty ugly compression settings that are hard to break through.
I'll also add, you are on a beta version, but I'm pretty sure that'll be an issue in an LTS as well.
Bruh the pics aren't cryptic it's just hard to show z fighting without a gif. Im looking for a way to fix the z buffer or work around it with shaders or something.
Yup, I'm sure you'll figure out. Good luck with that.