#๐โweb
1 messages ยท Page 7 of 1
Yes, and I just tested a previous build of mine and that worked too as you said. So ig itโs something with Unity ๐คทโโ๏ธ
Or memory
its iOS having extreme restrictions on RAM it seems
try and build your game on a lower resolution
that seems to fix it for us
at least atm
Is there a way for Unity 6 to put the โwe donโt run on mobileโ check back? References to where it was in the 2022 template might be enough.
My game is webgpu only so doesnโt work. At least on iOS.
And also has a LOT of code which sometimes seems to make it die on load with โstreaming compilation failedโ
The memory usage you see is not exactly correct on safari memory profiler. If you want to see exact memory usage, connect unity memory profiler to your build and use it. It ill not only show exactly what uses most memory, but also exact numbers which causes problems.
https://docs.unity3d.com/Packages/com.unity.memoryprofiler@1.1/manual/index.html
Also please have in mind the you should test on platform you have problems. One of main reasons is textures compression. For example if you test it on PC and your project is set to DXT format, memory usage will be lower than on iOS, as on iOS it will be decoded to RGBA, which is 4 times bigger format. This is extremely noticeable on VRAM, but I found that images size in memory (if not unloaded) can differ as well. I might be wrong here, but from my experience correct compression helped a lot with issues like that.
It looks like your server isnt setup for brotli compression. If you are just testing on your pc using the standard build method, change your PlayerSetttings > Player > Publushing > Compression Format to disabled. Otherwise look into configuring the server for Brotli.
Also the setting above that will come in usefull at times to debug when set to Full with Stacktrace.
publushing... ๐ I may have been guilty of this b4
Is there any way of exporting the localization assets... "raw" into the build? ๐ค
I want to change the localization without having to rebuild the game ๐ค
(I can probably do it by hand, with a json, but I lose the entire unity localization tools ๐ฅฒ )
Would rebuilding addressables be ok? I believe you can ship them as addressable assets.
Looks like you can do this without Addressables through a TableProvider https://docs.unity3d.com/Packages/com.unity.localization@1.5/api/UnityEngine.Localization.Settings.ITableProvider.html
ohhhh, that could be exactly what I want ๐
when i try to open my game in firefox this pops up
I think red text explains it better than anyone could. you cannot Just open index html, you actually need to host it on server (you can have it localy). Or just press Build and Run on Unity, it will work then, as it creates temporary server to run at.
Hey! I'm really struggling to understand the server configurations for brotli or gzip, my app runs without problems without compression, but I can't find any info for the content headers when hosting on something else than Nginx, Apache, and IIS servers (from the docs)
What is it running on then?
Render static site, also tried Netlify
You'll have to look up how to set up headers in those services and then add the necessary ones
It might not be possible in all services
Yeah I tried to look it up but I don't think it's possible, what do people usually use to host webgl (own website not like itch.io)
I think the most common ones are itch.io for hobbyists and studios have their own server infrastructure
I know Firebase Hosting lets you set up the headers but it's a more involved setup compared to Netlify and similar
You can control content headers (among other things) through netlify.toml. Documentation is on their site and people have posted templates for Unity content.
I came across it, but the netlify.toml didn't change anything, still had the errors concerning content headers
this was the template: https://www.ankursheel.com/blog/host-compressed-unity-webgl-game-on-netlify, also tried one from github
I believe it says something about rules being applied when you deploy the site if it's able to parse the file
Sorry I'm not sure I understand what you mean, is there a way to check if the file is parsed?
The docs of netlify just says that the nelify.toml file must be in the root of the project, so alongside the Build, StramingAssets and other webgl files, and the format of the [headers] corresponds to their docs so I don't really know if it's a step I missed or it just doesn't work
Also when inspecting the network tab the files does not have the Content-Header: br (they do appear with http:// instead of https:// tho, but the error remains)
Yea I recall seeing the output changing when looking at the deployment status. It went from just showing something about the files to also mentioning amount of rules being applied.
Haven't done this in a little while, so I don't remember specifics.
I see thanks, tried everything couldn't get it to work so I'll just keep that way for now and try the others ways.
Another quick question concerning webgl, when visiting my app on mobile the quality is horrible, but when I go into the web browser settings a click "request desktop device" quality is perfect (performances not affected), is there a way to have this quality by default?
edit: I could determine that it's because of the resolution, but I cannot find a way to adjust it as in webgl there is nothing in Screen.resolutions
edit 2: ended up fixing it with the display ratio within the index.html file
Just installed ios18 to test. Looks like still no WebGPU support?
Hi everyone, what do think is better to build the game like Seafight or Legend Pirates?
Unity or other such as Phaser, Threejs, Babylon, godot, etc...
Hope to hear from you.
ios dont have webgpu even on beta versions.. I wouldn't expect it to come anytime soon.
All depends.
Are you targeting only web platform? or you targeting multiple platforms. If multiple platforms then Unity is amazing choice.
Are you going to use assets to speed up your development? Asset store have tons of out of the box solutions that you can use, Unity is good choice again.
Do you ant to work with editor with convenient features and a lot of features? Unity is great choice then.
Do you focus purely on performance and to run as many mobile devices as possible? Chose Playcanvas or others web based solutions.
Want project to be as small as possible? once again, maybe Unity is not for that.
As I said it depends on what you aiming for. You can create Seafight or Legend pirate on all engines you mentioned. I personally would choose Unity as I like working on Unity.
He was asking between unity,godot,babylon and perhaps unreal engine i think
I understood that etc means: or any other engine. But my answer doesn't change, it all depends on what he needs. ThreeJS, babylon, Playcanvas is great for Web deployment, performance and project size is extremely good. But they lack in editor and features list. Unreal? I am not even sure worth to create Web application for it, it is just too demanding and for UE5, there is no official support if I remember correctly. Godot, it is great engine, and from gamejams information it replaced big part of Unity project (that mean webgl works, but how well, I don't know). And well Unity have problems with project size and memory limitations on older mobile devices is bit harder to optimize, but have very convenient development process.
The games he provided as examples can be made by all engines, what he targets is what important. So I cannot say: USE GODOT IT IS THE BEST, or something else. All have advantages and flaws.
No engine is as versatile as unity, so just use unity?
I'm going to build for web platform only. Unity's loading speed is slow at the first time. Currently, seafight is built with unity and not smooth as I think. even my pc is pretty good to play such the game.
anyhow thank you for the advice.
I thought so like you Godot before.
I like Godot idea, and I think it ill grow to great engine. I am just not sure its current possibilities. About loading speeds, in most cases is more about downloading assets than actually loading. So you really need to be carefull with what you add in your project and use correct compression. Use addressables to load only things that you currently need, for example initial load to load only main menu scene, and load resources for gameplay only when you need it.
Also there are ways to strip Unity engine parts that you don't actually need in order to minimize the size and increase loading speeds. But that requires quite a lot of work.
https://github.com/JohannesDeml/UnityWebGL-LoadingTest
I wouldn't necessarily put too much weight on the experience of old flash games converted to (or emulated in) Unity without knowing some technical details of the process.
Hey there. My boss needs a game exported in webgl. But he wants a javascript that can be changed even after the build. One that links to functions inside the build game. There seem to be many means of doing so. Any recommendations? I'm completely new to webgl.
Pick one that works and use that? This isn't the kind of choice that would have far reaching repercussions
Assuming you go down the Unity path
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
I am hosting a game server on multiplay which is using Mirror's simple web transport
my client is able to send request to the server and server receives it but after that the server restarts for some reason. Same setup is working locally but not on the hosted server.
One problem that i think could be cause problem is that i dont have ssl certificates setup locally, do i need to generate ssl certificate and set them up for wss connection? if not then what could be the problem?
Hello everybody
I just have a small question
How do I embed my unity webgl build to my live website?
Any way you normally upload files to your website. It depends on the site.
Has anyone compared the performance of WebGPU and WebGL on Unity 6 preview (0.20f1)? I tested a scene with over 10000 draw calls and enabled WebGPU support in Chrome, but it seems that there isn't much difference between the two
How do you guys use json to send payloads?
why won't webGL recognise up and down inputs from the joystick but it does from the dpad?
hey there. There is a mistake in this part, but I can't figure out what it is. Sitting on this for a few hours now...
{
let s = UTF8ToString(payload);
let bufferSize = lengthBytesUTF8(s) + 1;
let buffer = _malloc(bufferSize);
stringToUTF8(s, buffer, bufferSize);
return buffer;
},```
Hello everyone, Iโve tried just about everything to solve this problem but canโt do it. Iโm very new to coding and this is my first project. I got this from a tutorial for 3d but my game is 2d. The problem is when i remove the item from my inventory it wont let me pick it up. it first I thought it was because it was a clone but the way he did it it uses a string to identify it. The clones still had the string saved so I don't know whats happening. Hereโs a link to the โgameโ https://github.com/Kalani12345/2D-game
You'll have to give a lot more details
Does it happen specifically in WebGL only or why did you ask in this channel?
This is webgl | Unity 2022.3
I never tried it in any other context.
When I import it like this in my c#-script:
private static extern string testJsonExtern(string payload);```
I get this error:
This is the entire jslib-script for more context:
```mergeInto(LibraryManager.library, {
setHighscore: function(payload)
{
let s = UTF8ToString(payload);
s= UnityBridgeProfile.setHighscore(payload);
},
retrieveHighscore: function()
{
let payload = UnityBridgeProfile.retrieveHighscore();
let bufferSize = lengthBytesUTF8(payload) + 1;
let buffer = _malloc(bufferSize);
stringToUTF8(payload, buffer, bufferSize);
return buffer;
},
testJsonExtern: function(payload)
{
let s = UTF8ToString(payload);
let bufferSize = lengthBytesUTF8(s) + 1;
let buffer = _malloc(bufferSize);
stringToUTF8(s, buffer, bufferSize);
return buffer;
},
});```
Is the jslib in a file with a .jslib extension and placed in Assets?
Did you save the file?
of course.
Doesn't really make sense why the two other functions would work but this one not. Does it work if you change the name? Maybe "extern" messes it up
Maybe.... Let me try that
... I found the error. I uploaded the project to github for my coworkes, but still edited the old file outside my the branch... God dammit.
It works... Yaaay... ๐
Sorry I donโt use dicord a lot and didnโt notice
Hello i want to ask something im not sure where to ask but here is the question im using is AWSSDK and is the pre-signed-url feature is not working in WebGL? since after few debug the error always right there. Oh btw its works perfectly in editor its only doesnt works in WebGL build, Thanks
does AWSSDK even support webgl? as if plugins is not in JS, it won't really work on Webgl. You should look if there is something like: Javascript SDKs of AWS
you can read more here https://discussions.unity.com/t/aws-sdk-for-webgl/917538/6
oh my god right its not support WebGL
if using Unity Web Request does that mean the server need to be publicly accessible so unity can also get data from the server?
Depends what you mean by publicly accessible
obviously if you want to make a request to a server then you need some kind of access there
WebRequest is unity specific html requests, it just don't use some specific libraries and uses Unity libraries instead. Technicly if you could find all requests in that plugin and replace to UnityWeb request it might even work. But I wouldn't suggest to do it, as there might be other problems, like threading, which will still won't work on webgl.
yes so what i mean is i want my server is private so no one can access the data via url, but if unity is the one that request it then unity can still get the data, is that possible? im not to sure if what im saying is make sense xD
you can block incomming data. But only accept responses to your requests. It is possible. but that is not unity server problem it is server machine setup it self
ah yes i have problem with threading previously
i dont know hehe
Well figure that part out first. Right now you're basically asking "there's no way to access data on my server. Can Unity get the data from that server?"
i see so if we want to do that, thats need to be something that processed by the server not unity
xD
I would not think too much about it first. anyways you will want your unity server to be accessible by clients anyways. you can always block access later
Also note that it's impossble to set it up so that only your game can access the server and nothing else
yea thats probably true
i see okay
Thank you all i will ask again about this later after i have more question, Once again Thank you
I got this issue when the scene changes. (itch.io)
Not only scene changing. When I click game , I get that issue
See your browser JavaScript console for more info
Hey, I've been getting this error/outcome inside a build only (it works fine in the editor) when calling a .jslib that awaits for the outcome of a popup, any thoughts on why it sees the popup window as closed right away even though it's not?
googleIdentityServiceInitializeCodeClient: function (initCallbackPtr, clientIdStr, scopeStr, callbackPtr, errorCallbackPtr) {
googleIdentityService.googleIdentityServiceInitializeScript((err) => {
dynCall('vi', initCallbackPtr, [googleIdentityService.allocateUnmanagedString(err)]);
}, () => {
try {
googleIdentityService.client = google.accounts.oauth2.initCodeClient({
client_id: clientIdStr,
scope: scopeStr,
ux_mode: 'popup',
callback: (response) => {
if (response.error) {
dynCall('vi', errorCallbackPtr, [googleIdentityService.allocateUnmanagedString(response.error)]);
}
else if (response.code) {
dynCall('vi', callbackPtr, [googleIdentityService.allocateUnmanagedString(response.code)]);
}
},
error_callback: (error) => {
dynCall('vi', errorCallbackPtr, [googleIdentityService.allocateUnmanagedString(error.type)]);
},
});
googleIdentityService.isInitialized = true;
dynCall('vi', initCallbackPtr, [googleIdentityService.allocateUnmanagedString('')]);
} catch (error) {
dynCall('vi', initCallbackPtr, [googleIdentityService.allocateUnmanagedString('[WEB GIS ERROR] ' + error.message)]);
}
});
},
does unity webgpu work with ecs? or itโs mono behaviour only?
Up
help guys
I don't know what Telegram JS SDK will let you access, but if you can access that information from Telgram API to JS then you can pass data from JS to WebGL following this:
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
It is not secure tho in My opinion.
Another way is to use WebRequest and talk with your on Telegram API.
But both requires good knowledge of Telegram, which is bit hard ๐ฆ
hey, anyone knows the trick with CancellationTokenSource in webgl builds?
I call a _cts?.Cancel(false) where false explicitly states not to throw an exception, but in webgl builds it throws anyway
ObjectDisposedException: The CancellationTokenSource has been disposed.
at System.Threading.CancellationTokenSource.ThrowObjectDisposedException () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.CancellationTokenSource.ThrowIfDisposed () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.CancellationTokenSource.Cancel (System.Boolean throwOnFirstException) [0x00000] in <00000000000000000000000000000000>:0
I managed to do this without the SDK's help
Webgl don't support Threading. Code or asset you are using will not work on Webgl.
but cancellationtokenSource doesn't use threading
does it?
afaik it uses a simple data model where the data is managed and shared between asynchronous states. so any Task or async voids can access that data
Webgl dont support tasks either. If you want use them you will need to use UniTask library for that.
nah that's not correct. Task isn't multi-threaded by its nature. It's well supported in WebGL
just don't use functions that use different threads like Task.Delay. but others like Task.Yield() are fine. I've used them for years with no problem
Sorry, I just don't count it working when big part of library doesn't work on WebGL. So I wouldn't be surprised if that part is dependable on something that does not support webgl. What you can try just put part of code in try/catch logic and handle error handling depending on platform. So you will end without errors?
yeah it seems like I have to build my own cancellationtoken feature. looked up online and there's zero references on this anywhere, kind of surprising
๐ฅฒโ
If project webgl only, I really suggest using UniTask, it's cancelation logic is identical and it works on webgl without problems for sure.
thanks for the tip, yeah I looked into that project, it adds unnecessary overhead tbh. the system is already simple to create. it's already done actually, created SafeCancellationTokenSource and SafeCancellationToken under the same namespace as the normal ones, and from there it was a simple replace-all in Rider
Render texture not working on WebGL build, there is only a black part at the bottom-left corner showing instead of the camera render, In editor Render texture is working just fine. how to fix this issue on webgl?
Google WebGLFirebase and open the github repo. It's what I use and it works.
that's the one
Is Unity CLoud good for this?
I haven't used it
render textures works on webgl for sure. But you can have here several problems. More common one would be solved if you would manually refresh texture after you are sure that camera is rendered something in it. (pretty much it thinks that there is no new data and don't render anything.)
other problems could be texture format or settings, you can try playing with that.
@astral wave Thanks for the help, can you help me how to refresh the texture at runtime? I have tried this code but still not working on Web void Refresh() { SecondCamera.Render(); Graphics.Blit(SecondCamera.activeTexture, renderTexture); }
for testing you can try just add button that enables and disables your texture, if after disabling and enabling it again it shows correct image, then you will know that is the culprit.
Depending on where you rendering, some of elements have dirty feature: ImageRenderer.SetAllDirty();
This is texture settings that most definettly works on webgl. I am sure most of it does work, but just in case.
@astral wave Hi, I did what you suggested by disabling and enabling RawImage and setting the value of RenderTexture the same as your image but still no render appears on the Web build(It works perfectly on Editor). you can see my code and RenderTexture setup. Thanks!
hmmm, try reinialise your code on button click, the one that enables camera and passes texture to the element. Can you share you texture settings and initialisation code where you enable camera and set target to the texture?
@astral wave I set RenderTexture to the camera in inspector not within the code
hmmmmmmmm, what else could it be. Could you try something:
-create 3D cube and put the texture on it. Then we will know if that is UI problem or other problem. (as UI sometimes dont like to be refreshed correctly.)
@astral wave ๐ Its work on cube but not on RawImage, I use RawImage because i need it in UI
so you setup is like this right?:
What shader does your meterial use?
@astral wave URP Lit
you will need to change URP to different shader, UI/Default or something. I am building right now webgl build to test, but shader is incorrect for sure.
@astral wave ๐คฉ Its Work! Thank you so much
Glad to hear it worked ๐ good luck
@astral wave You save my day thanks!๐
Hey. Anyone used unity 6 webgl yet? Any particular bugs?
i have a question
so if i publish my unity game with webgl
and after that i make changes to the game
the webgl game will be automaticaly updated?
Players will update when they refresh the page, but you would still need to upload builds to your web server.
I'm suddenly getting this error for unity webGL. I've tried turning off toggling decompression fallback made it work for a day then the new build got the error again.
Worth noting that I'm getting the error on my old itch webgl games that used to work correcly. did itch change something?
please I need help. I need to get the webgl version running. I don't know if this is only happening to me. There is no reason for old working builds to fail like this. But they are failing even if I switch browsers or even devices
@pastel bobcat select "Full With Stacktrace" and see the full log on the browser for error log
How are the build sizes with Unity6? Are they viable for simple 2D games on platforms like Poki, YandexGames etc?
You can find reasonable baseline numbers here https://github.com/JohannesDeml/UnityWebGL-LoadingTest
Anyone knows?
Still havent' found a solution
In Unity 2022.3.20 version webgl build, a click sound is heard every time the audio loop repeats. How can I solve this?
anyone else having general audio issues
I have a PNG hosted on amazon cloud and I get it at runtime via a UnityWebReqestTexture.GetTexture(url)
It works fine on Editor
but when I load the webgl game on website like Itch.io I get CORS error
is it due to the site policies or Amazon security policies?
Amazon
Just to be sure here's the error I get
Access to fetch at 'https://xyz.cloudfront.net/image.png' from origin 'https://html-classic.itch.zone' 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.
Yes, the server must send the appropriate CORS headers with the image
hi.
we have deployed an upgrade to our web page which is a webapp, PWA and all that. it's a Unity webgl build, if that's important.
iOS browsers Safari and Chrome keep using the old JavaScript files from before the upgrade, even in incognito. is this a common iOS thing? are there any solutions for this?
I'm sending no especial header, but it's been more than 1 week since then now, and iOS browser still use the old version...
Has anyone encountered this issue while building for the web It takes 20 to 25 minutes to make, and progress stops at linking build.js (wasm) for 20 minutes. Is there any solution for this? I am using Unity 6 LTS and the same issue occurs on 2022 LTS
Well that's the long part so it's normal to take long. 25 mins? That depends on your hardware
@amber ginkgo Previously on the same hardware and the same project, it takes 1 or fewer minutes to build.
Are you sure? Webgl takes more than that for an empty project on a decent hardware
is webgpu already available on unity6?
I think it is but you need to enable it. I'm looking up if the steps are available somewhere.
so is it still in some sort of preview?
It's still experimental
ok thanks
I have a build of the unity webgl game, but when I uploaded it to the hosting, it stopped loading after the initial download window appeared,what to do?
Does webgl build support URP decal projectors? Desktop build looks fine but can't see the decals on webgl.
Hey guys. i'm doing a small game in unity for a sort of game jam here locally, and they're asking us to make it playable on web, on itch.io. is there any limitations to this? Or can I just make any game use the extension and it'll be playable on web? Just a short game 10-15 mins, low poly.
I heard there was a certain build profile or something
Check browser's console for potential details
Might need to change decal rendering technique https://docs.unity3d.com/6000.0/Documentation/Manual/urp/renderer-feature-decal-reference.html
Just changing the build platform is enough. Make sure you have the module installed (can be added through Unity Hub if not). Things work within the limitations of WebGL, WebAudio, web input, no threading and generally limited access to platform features, but this generally just works for most games. https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-develop.html
Just make sure to test early in case you do happen to bump into something.
Thanks. It was set to automatic (so depending on build) but I'll try each one out.
how do you guys normally debug webgl builds? I get an error in the chrome browser development console, but it looks gibberish.
Connecting to ws://127.0.0.1:8000
FishBait.loader.js:1 Invoking error handler due to
abort() at Error
at jsStackTrace (http://localhost:3000/FishBait/Build/FishBait.framework.js.gz:4301:21942)
at stackTrace (http://localhost:3000/FishBait/Build/FishBait.framework.js.gz:4301:22205)
at abort (http://localhost:3000/FishBait/Build/FishBait.framework.js.gz:4301:992)
at ___cxa_allocate_exception (http://localhost:3000/FishBait/Build/FishBait.framework.js.gz:4301:85538)
at wasm://wasm/0b425e5e:wasm-function[1652]:0x135103
at wasm://wasm/0b425e5e:wasm-function[1875]:0x144d68
at wasm://wasm/0b425e5e:wasm-function[46099]:0xfbab7d
at wasm://wasm/0b425e5e:wasm-function[119769]:0x27474d8
at invoke_viiiii
do you guys always enable exception with full-stacktrace for a webgl build?
Depends on the Unity version, you can make the names of functions more readable.
I think development build does it. But sometimes you want this to debug release build.
You can use
PlayerSettings.WebGL.emscriptenArgs = "--profiling-funcs";
Or edit the emscriptenArgs on the projectsettings.asset file.
More info here:
https://medium.com/@depanther/unity-webgl-secrets-b6ddf214f1fd
Thanks. didnt know about --profiling-funcs . will give it a try
I have a problem with WebGL not using the camera's solid background color in fullscreen mode: (please ignore terrible UI scaling, thats a separate issue)
What am I doing wrong?
I have a strange issue where certain animations are playing at a much slower rate in the WebGL build of the game than they do in-engine. Any ideas where I should start looking? The overall framerate is still normal, just some enemies' animations are playing at a lower framerate for some reason.
Anyone have the issue of a game not updating on the website after making changes despite, doing a clean build of the game, replacing files, cleaning and rebuilding the app? lol
The game works with changes and everything if I just do a build & run as well as in the unity client itself, but i'm having a hard time figuring this out lol
On website you need to deal with cache. If it for testing purposes, just do hard page reload or open project in incognito mode. For production you might want add versioning into acount. The easiest way is to have files with new unique name, then it wont be cached. Another solution dpends on your websit provider, most of them lets you clear cache manually.
"Name files as hashes" option in web player settings handles renaming Unity files for you
so it seems websocket-sharp doesnt really work with webgl, whats a good alternative library for websocket networking?
Any Unity supporting websocket transport that comes with jslib files will probably work. https://github.com/James-Frowen/SimpleWebTransport is used by Mirror and Mirage.
is it just me or Unity 6 webgl is very unstable?
I've tried to translate my Unity 2022.3 project into Unity 6 either by changing editor and by creatimg a blank project and reimport all but the I got stuck on webgl loading screen with no errors
would love your opinion on this, atm i'm on 2022.3.8 and it's very stable, what version were you on before?
as I said 2022.3 maybe .22 dont remember but I don't think that minor version will make the difference
Maybe its some dll I'm using but the console isn't giving me any useful info about the problems I'm having
and that is just with using webgl2.0, I haven't even tried WebGpu yet
hehehe i think it does ๐ saying that as a person who released 2-3 games and spent over 7-8 years in unity
well then just duplicate your and let me know cause I'm curious
I expected that upgrade to be way smoother
even cause my project isnt that big
WebGPU is also the reason why i want to try and switch, but i de-installed when my fonts were blurry in the editor. I can change the text sharpness in the settings, but it's either too sharp or not sharp enough somehow
I got disappointed to know its still in preview honestly
they pushed it so much as Unity6 feature but officialiy is not completed yet
I see
yeah me too, i'm creating a mp shooter btw with NGO
nothing too fancy yet, just a web shooter
i read it's also a part of 2023.
lots of people with bugs tho xD
but maybe interesting to checkout soem latest messages, some people do have it working, also some talk about unity6
when you were copying files in new project, did you copy Library folder as well. Its common that library folder cause problems on version upgrading. You could try deleting it, and then opening project again in version you want and let Unity regenerate it. I only used unity 6 with small webgl test projects, but have not find any problems yet.
I did not, I created a new project from 0 and imported the scene as unitypackage with its dependencies
could it be some dependencies needs to be updated first? I mean some older packages might need to be updated if you using a lot o them. Sorry hard to tell without knowing project.
Im 100% sure its all up an running, in fact it all works in editor, but when playing on webgl the website literally freezes when the loading bar reaches the 100%
and I have no info in the console so I really dont understand what is going on
have you tried loading in dev mode? and connecting profiler to it?
the only thing that I still need to do is connect the editor console to the build running
but I got quite demotivated at least for now since I'm seeing that a lot of WebGL devs are complaining about problems regarding the Unity6 project import
I know it is stupid question, but are you sure than in scene list the correct scene is selected when you build?
there is only 1 scene
I had once after upgrading that it was not open scene inside, but had same name.
and before Unity6 the webgl worked on everything, even android and iphones (which was a mess to deal with but at the end everything worked)
Anyone run into black screens + RenderPass: The dimensions or sample count of attachment 0 do not match RenderPass specifications in built games for WebGPU in Unity 6? I suspect it's related to render texture usage, though I've had similar projects work fine in 2023.3beta
I have been trying Unity 6, and using our custom WebGL Templates from previous versions, however keep getting a strange error that doesnt make much sense to me.
Preprocessor error "ReferenceError: USE_WEBGL_1_0 is not defined" occured in file "C:/Repositories/ProjectName/Assets/WebGLTemplates/CustomTemplate/index.html" when evaluating expression " USE_WEBGL_1_0 "
The documentation shows that it still exists, as it did in previous versions, anyone else running into this issue? or perhaps know what has changed so that its no longer recognizing it?
https://docs.unity3d.com/6000.0/Documentation/Manual/web-templates-variables.html
https://discussions.unity.com/t/removing-support-for-gles2-and-webgl1-in-2023-1a/899819
Could be a mismatch in template documentation and the state of Unity itself.
**[Solved] **
Edit: there was an error inside the C# method being called but the thrown error wasn't being clear what the issue was.
~~I'm using this C# method to call the code in the jslib
public static extern void GetAnnotation(Action<string> result);
(...)
GetAnnotation(AnnotationsCallback); // call .jslib method
Then the method in the .jslib is called and I query a string from my database, which returns with success:
var notes = await window.unityInstance.user.getAnnotation();
var bufferSize = lengthBytesUTF8(notes) + 1;
var buffer = _malloc(bufferSize);
{{{ makeDynCall('vi', 'callback') }}} (stringToUTF8(notes, buffer, bufferSize));
}
And this is the method it should call with makeDynCall:
[MonoPInvokeCallback(typeof(Action<string>))]
public static void AnnotationsCallback(string returnedStr)
{
Instance.noteInput.text = returnedStr;
}
But the method is never called, instead I get an undefined exception on the browser console with just some random number.
These methods were basically copied from the documentation:
https://docs.unity3d.com/2022.3/Documentation/Manual/web-interacting-browser-example.html~~
Show the full error message
and just in case write file location directory ๐
The error messages aren't helpful, it's always some random number sequence so I can't figure out what is wrong.
Have you confirmed that it's not the user.getAnnotation call that's throwing the error? If you replace it with var notes = "test"; does it still throw?
I did, the debugger returns the string just fine.
Which line throws the error then?
It was the makeDynCall but now I figured out that there was an error inside the C# method being called.
maybe the random number was because it's unmanaged code being called
Also it seems like the correct way to make the string conversion is by using stringToNewUTF8
just installed unity 6 to test out the improvements with web builds
https://discussions.unity.com/t/unity-6-updates-for-platforms/1529798
"Now, you can run your Unity games anywhere on the web without limiting your browser games to desktop platforms."
How exactly? The same way as before by installing Web as a build platform and building to Web?
"Additionally, you can embed your games in a WebView in a native app or use our progressive web app template"
That sounds cool but how?
Is there some kind of switch I need to flip or do I just make a Web build like I always do?
Mobile browsers are just officially supported now. Part of Unity committing to mobile browser support and part those browsers and platforms becoming more capable. There is a PWA template, but I'm not too familiar with the mechanics of it.
Webview support is probably a similar situation.
Correct me if this is the wrong place to ask but is anyone working on or know of an existing game on the web that is a virtual world where you customize your character, chat with other people, play mini games, decorate a living space, things like that.
I already know about frog Paradise and hedgehog Creek! Thank you! Ping me your responses!
More detailed error for the black screen caused by render texture in WebGPU:
[Texture (unlabeled 640x360 px, TextureFormat::RGBA8UnormSrgb)] usage (TextureBinding|RenderAttachment) includes writable usage and another usage in the same synchronization scope.
- While validating render pass usage.
- While finishing [CommandEncoder (unlabeled)]. Project.framework.js.br:9
[Invalid CommandBuffer] is invalid.
- While calling [Queue].Submit([[Invalid CommandBuffer]])
https://theportal.to/
I think one of better examples. Well it is full of crypto, but some people like it. There are others metaverses as well. Most of them have some or all of these features. If needed i can give more, but they are quite behind in comparison with theportal.to. Also it is created on unity so you will get good image what can be done. Sadly it does not work on mobiles, at least yet from what I remember.
Thank you!! I'll look into it.
Do you know of any 2d ones?
2D is rare ones, I have saw only one I think, it was japanese application for remote work. It had all features you mentioned, but I cant remember th name now at all.
so most of them I saw was remote office, like "Gather" and etc
Thanks for taking the time to answer my question!! As someone who played games like animal jam classic and club penguin, I miss 2d virtual worlds that are MMO.
Has anyone ever gotten an error like this in a WebGL build?
Ive been searching everywhere but cant find a fix
My project is pretty barebones
Works in the Editor on Web Platform and with multiplayer mode
Unity 6 LTS
If you've made your own JS plugins you'll have to use makeDynCall instead of dynCall. If not, you'll have to disable the WebAssembly.Table option to make the old dynCalls work
I havnt made any js plugins. Just unity 6 and the multiplayer sdk really. Where would I find and change this?
Edit > Project Settings > Player
Is there a way to host the .wasm file in a different location than the rest of the game? I tried editing all the references to build.wasm to just https://example.com/build.wasm but that doesn't work
https://discussions.unity.com/t/disabling-splash-screen-causes-black-screen-on-some-devices-unity-6000-0-0f1/947210/6
Also I am having this issue. Does anyone know a fix?
You'll need to set the correct headers for the wasm file server, at least CORS headers and content-encoding if it uses Brotli compression. But it depends what the error is.
For the splash screen, you'll probably have to wait for an editor update
wait.. it seems to just be VPP messing up. The Professional edition has it fixed but they didn't update the Community version
I am trying to build DOTS Project for webgl but it keeps crashing. Is DOTS still not support for webgl?
I fixed it by moving all files to a different place instead of only the wasm file
Depends on which parts of DOTS you are using. I wouldn't expect ECS, Jobs and Burst to crash, but Entities Graphics might.
Jobs and Burst generally range from not being very effective to being unsupported, but I imagine they have fallback mechanisms that get a lot more testing.
How can I send browser push notifications from a WebGL game or my backend, can't quite find info on it in Unity, I assume the game would need to ask for permission first?
You'll have to research how to do it in Javascript and make a JS plugin
Do somebody have knowledge on using the NativeWebSocket library?
I'm using it to enstablish and manage a websocket connection that works also on WebGL build.
It worked like a charm until I added a header, in this game the connection only works on editor
Hello, can someone help me with getting the Unity player on a custom site? I tried pasting the html to the right part and the stylesheet to the <head> part, and it does work, but it doesn't show the full screen button
So I copied the part between <body> and </body> to the right part of the html and I copied the <link rel="stylesheet" href="TemplateData/style.css"> to the <head> part
Actually, for cross support, would checking for (dynCall === undefined) inside .jslib tell us that we need to use makeDynCall instead of dynCall?
There is also a forum thread for .jspre not working when 'Decompression Fallback' is on. Does anyone have the same issue with it? Saw that forum thread randomly today, asking just in case if .jspre is known for being not reliable
Hey, when using webGL build on a website i often get an error in the console saying:
still waiting on dependencies
dependency: wasm-instantiate
(end of list)
and the game is stuck on the loading screen. Any idea how to fix this?
Does somebody know how to fix this error. I am trying to build on WebGL with URP on 2023.2.20f1
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.RenderPipelineGraphicsSettingsStripper.PerformStripping (System.Collections.Generic.List`1[T] settingsList, System.Collections.Generic.List`1[T] runtimeSettingsList) (at ./Library/PackageCache/com.unity.render-pipelines.core@16.0.6/Runtime/Stripping/RenderPipelineGraphicsSettingsStripper.cs:43)
UnityEngine.Rendering.RenderPipelineGraphicsSettingsContainer.OnBeforeSerialize () (at ./Library/PackageCache/com.unity.render-pipelines.core@16.0.6/Runtime/RenderPipeline/RenderPipelineGraphicsSettingsContainer.cs:44)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Update Unity to the latest Unity 6 LTS @tall lantern
Hey guys, we are trying to deploy to webgl a game online and i seem to be having issues with Iphones, i know they require ASTC compression but for some reason they still are not able to run it the pages say a proble repeatedly occured, works fine on dekstop, works fine on android
hi gang
I made this using chatgpt and
it's working nicely, except for loading the file
made a thread to avoid flooding
the error I'm getting says that Unity is not initialized
this is where my console on the browser is referring me to
also, do WebGl lose quality when built? ๐ค
https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-server-configuration-code-samples.html
Maybe you did not setuped your server to support wasm. Just a guess.
this one answer is: it depends ๐
- when you build there a specific build options that will compress your textures to specified quality and format. Which could lead to some noise and quality drop after the build.
- When you build and run webgl, you will notice that the window resolution is quite different from what editor runs at. And the comes the real enemy -< SCALING. And scaling can cause really a lot off quality problems. Like image instead o 512x512 becomes 269x269, where you lose data and some pixels can look different making it look bad. It can be solved with adjusting html code and build options.
- by default project have quality settings: high, medium, low. And they are set to be default different depending on the platform. So in short on webgl it might change to lowest quality settings option ๐
it is always better to check console for more precise error. (f12 on chrome for example). Make sure to check there, then make sure the loading order of you script is correct, like unityInstance is not defined after actually using it. And check the template code, as unityInstance name changed depending on unity version.
well all I get is this
https://docs.unity3d.com/es/2018.4/Manual/webgl-interactingwithbrowserscripting.html
https://docs.unity3d.com/6000.0/Documentation/Manual/web-interacting-browser-unity-to-js.html
make sure you template have something like this:
var unityInstance= null;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => { /*...*/ }).then((unityInstance) => {
unityInstance= unityInstance;
Aka make unity instance into global variable that you can easily access.
When building content for the web, you might need to communicate with other elements on your web page. Or you might want to implement functionality using Web APIs which Unity does not currently expose by default. In both cases, you need to directly interface with the browserโs JavaScript engine. Unity WebGL provides different methods to do this.
I don't get this much... it's my first time using webgl
id depends which template you are using. Normally the place you have your js code to load unity. It can be in index.html or other location. depends on project and template.
okay so put that on my html
where would I put that exactly tho?
createUnityInstance(canvas, config, (progress) => { <..> }).then((unityInstance) => {
unityInstance = unityInstance;}
and write other code you need. Or something like that.
If you would using unity 6 template you could see something like this:
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
document.querySelector("#unity-progress-bar-full").style.width = 100 * progress + "%";
}).then((unityInstance) => {
document.querySelector("#unity-loading-bar").style.display = "none";
document.querySelector("#unity-fullscreen-button").onclick = () => {
unityInstance.SetFullscreen(1);
};
<..>```
which gives you place where to look.,
var unityInstance;
createUnityInstance(document.querySelector("#unity-canvas"), {
arguments: [],
dataUrl: "Build/Jaro TCG - Web DeckEditor.data.br",
frameworkUrl: "Build/Jaro TCG - Web DeckEditor.framework.js.br",
codeUrl: "Build/Jaro TCG - Web DeckEditor.wasm.br",
streamingAssetsUrl: "StreamingAssets",
companyName: "Devour Labs",
productName: "Jaro TCG - Editor de Mazos Web",
productVersion: "0.1.0",
}).then(function(instance) {
unityInstance = instance; // Assign to global variable
document.getElementById("loadingMessage").style.display = "none"; // Hide loading message
console.log("Unity instance created successfully.");
}).catch(function(error) {
console.error("Failed to create Unity instance:", error);
document.getElementById("loadingMessage").innerText = "Failed to load Unity app.";```
oh, didn't know about these templates
I used chatgpt for what you told me, I haven't tried yet but will soon
I bet something else will now have an error but at least is one step in the right direction xD
yea chat gpt likes dream a bit on unity webgl ๐
tomorrow I'll check back on this and take a look at what you sent
thanks for caring even if it doesn't work, I appreciate the effort xD
also would like to know where exactly I should look into to make my cards look clearer
I tried changing the texture compression format and such... that took one hour and made no difference xD
first check quality settings and platform connection in player options /quality ->
There green color indefies which quality setting is default. And icon with small 5 (last icon) means WebGL platform.
Yes i fixed it by recreating urp assets
Researching if Unity's new input system doesn't allow key rebinding in WebGL, or if there is any documentation on keyrebind WebGL specifically.
Having issues with it? Not aware of such limitations, but you could try building one of the input rebinding samples to make sure.
Hello friends, I have a cache issue in my WebGL build. I update my app on the server a few times a week and can not see the updated version without a clear cache in the browser. Here are my WebGL player settings. I want my app updated when I upload the latest build to the server without manually refreshing the cache. Please help me!
That sounds like a server / browser issue, not the webGL part. As long as your website is not forcing the cache to be cleaned, it will remain, as the webgl wont have access to delete files on the users machine
@torn pagoda that's correct we can not handle browser caching from the Unity side, but I update my app daily so it is necessary for users to clear previous caches to get the latest version.
Again, thats a server issue on the config, how long it will store the latest build or on the users browser. I think, you need to serach for some website specific cache configs or server side configs to change instead of the unity build settings
Tick Name Files As Hashes to make sure changed Unity files have a different name to reliably prevent caching anywhere in the chain. I would keep data caching on.
Cache busting of files other than the ones Unity builds needs to be handled separately, but the strategy would be the same.
Can anyone help me uploading game on Telegram
what is the best format to use for video in unity webgl
I've uploaded my Unity 6 web game to Itch.io and tested it on Brave mobile browser & Chrome mobile browser and it works fine but on Firefox it doesn't correctly rotate into landscape mode, it says in portrait mode, and in Edge browser there is no sound.
Would anybody happen to know how to make the game more compatible amongst all the different mobile browsers? I guess it comes down to the browser's privacy and media autoplay settings?
Using Unity 6, still have pop sound when loop sound
How to solve this?
I want to make seamless sound loop
Result should be like this
ok
here is sound
1 sec beep
This sound has no empty area
it working fine here
its building now
This is my setting for isolate testing in blank project
Didn't touch anything in the audio import setting
Building
Hi, so, maybe my question is best asked here.
I'm trying to hook google analytics into Unity for a desktop game so I can publish it on itch. All information I can get about how to do it is aimed towards Android and iOS. Does anyone know how to do it or share a link to a website/video that explains how to set it up?
thanks!
This channel is for WebGL so it's not the right place. But the instructions are the same for all platforms: https://firebase.google.com/docs/analytics/unity/start
Thanks for the answer. I forgot to clarify, the itch version is supposed to be in WebGL, not sure if the process is the same for desktop.
I checked the firebase documentation and it only explains for mobile, and in the app setup it tells me to pick if it's for iOS or Android (or both), so I'm not sure how to do it if I'm just having it from web.
What app setup?
this thing here.
Some context, I've always used in-house analytics so I'm not sure how to set up and work with firebase and google analytics.
Use the web app template (</> button)
oh ok, so just normal web and doesn't matter if it's unity or not, got it. Thanks! ๐
Do you know by any chance if doing this would work for desktop apps?
Ok I built web build, and testing
Same issue on blank project
Yes, all of them do the same thing. The only difference is what instructions it shows after adding the app
@halcyon hedge how about ur?
ohh! that's awesome!
Thanks!! โค๏ธ
I u said it was web build?
yes but its still building, i think it got stuck cause my battery died
It build long for me too
I'm using SSD but was too long
โณ
Are you using HDD?
HDD was too slower than SSD
I found some asset package is postprocessing audio, so removed all and try re-build
no Im just doing it normally but my laptopfroze and I think it interrupted the process. Im just going to try my desktop, be back in 10
Aha I see. Thank you to testing
This build is same on chrome and firefox (+edge)
ok confirmed, okay something is definitely different on webgl
same with my video?
the pitch is also lower
Oh didn't know that
web build force to usc AAC compression
yes there is a higher pitch in the editor but its a lower pitch webgl
hm then it is issue of AAC ompression in the unity it self.
also did u hear pop sound?
not so much of a pop but yes its like a silent space
idk if its a bug or just wrong exporting settings, I would need to try different things around settings and see further whats going.
Aha ok, I think setting will force to set like this
There are few option to change setting here
there are other settings too iirc
I assume unity compress audio format to AAC, but it make small void area
I can only see this setting
apparently Unity uses heavy modded verison of FMOD but in webgl they dont
Oh
That would be reason
Then If it is caused by leak of FMOD in webgl. I think there is no solution now?
I found all supported audio format
and I remember mp3 had more delay for each loop
forum suggest to use wav to seamless loop. and i also test .ogg, it is also not working
I just told you FMOD is NOT what they use for web, they have to rely on the built in web apis
thats whats causing issues
here found this this explains further of looping issue https://discussions.unity.com/t/seamless-audio-looping-in-webgl/1497212/4
Oh I see and thank you to share, I saw this before but now staff added new comment !
I should try it
yes it sucks that web is this way, but it is what it is
if mac build works well, i think it was also working well on your laptop
by the way, i found FMOD with unity web
I didnt understand this 'Support for WebGL is included with the base integration'
FMOD support WebGL basically?
Also found official sample
You can try it and see
cause the docs says this
Because Unity uses FMOD
to manage audio for platforms, the Web platform supports limited audio functionality, which only includes the basic features. FMOD relies on threads, which the WebGL
API doesnโt support. For this reason, Unity uses an implementation based on the internal Web Audio API, which enables the browser to handle audio playback and mixing.
Oh Thank you
hm. I also tried to this method. can't find smpl chunk with hex editor
So I just should fade in / out audio start and end
Im facing a weird issue with WebGL builds on Safari. It seems to be a Safari bug of kinds.
What happens is on first load, it will load the game in to memory, but after every consequent reload, it just adds more and more to the memory unless i complete shut off safari and re-open it..
It get's more weird though, i've tried refreshing the game a couple of times (going from 600mb, to 1gb, to 2gb, to 3gb, etc..) and then switching to another domain (nu.nl), in which case suddenly, the nu.nl safari page keeps using a whopping 6gb of RAM and keeps automatically growing without me even doing anything.
I've attached screenshots of my mac Activity Monitor, to show it growing as I reload, and the switching to nu.nl and it continueing to use so much RAM..
(3 reloads on game, then switching to nu.nl, then a couple of seconds after nu.nl load)
Hi Im wondering is there's any function i can use to clear cache of my webgl game?
So the problem is if user already open the web(im using AWS s3 bucket) then i update the web, the user wont get updated build and user need to clear cache of that web first to get that updated build, so i want to solve that issue, is there's anyway i can do to achieve this?
i research a bit in unity discussion and some of them said delete IndexedDB.deleteDatabase, but when i tried it said Database Detection Blocked: /idbfs
Database Detection Blocked: UnityCache
And yes that 2 is the one i need to delete based on unity discussion i read, any idea on this?
not sure whether to post this here or in #๐ฑโmobile but i published a unity 6 web game on itch.io intended to be played on mobile and it works on brave browser and chrome but in firefox it doesn't go into landscape mode properly, is there a way to fix this?
i tried Screen.orientation = ScreenOrientation.LandscapeLeft; but it didnt do anything
Hi, what I need to do to make the Gyroscope/Accelerometer work on the publishing platforms like itch.io or CrazyGames?
I created a Unity Asset that works via local Wi-Fi testing with HTTPS self-signed cert. But one of my clients says that it doesn't work when uploading a Unity WebGL build on the itch.io.
My Detailed Post on Unity Discussions: https://discussions.unity.com/t/gyroscope-and-accelerometer-sensors-on-webgl-using-itch-io-or-crazygames/1555386
how would i make a webgl file of a unity game
it was pc mac platform
now i put it to webGL and it bombarded me with errors
when i tried to build it
Deal with them? It's a bad practice to tell that you are getting errors without specifying them. As far as I know not every aspect of unity can be utilized on WebGL, so you might be having to redo something. Also, I might be wrong, but you are never getting a webgl file. You re getting a Build in a folder with... subfolders and stuff in it.
Hi guys, i have a question. In our current company we are planning on publishing our games on our own site and so we need to show game ads, since sites like Poki etc provide their own sdks for ad integration, is there any sdk available that is not attached to a publishing platform for webGL? something we can use independently?
Any browser advertising solution can interacted with through https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html. Adinplay is one that specializes in this space and helps to shield you from mistakes that could get you banned from big ad networks.
Thanks
Okay, this is a bit of a stretch, but I'm out of options and I can find nothing online that works. Has anyone here ever managed to get a Unity WebGL build running in a Blazor Web Application? I'm pretty sure I've got all the files in the right place, but it's giving me a 404 when trying to load the JS. I've put the build directory in wwwroot and added the contents of the index.html to the page I want, but it just isn't loading anything.
The closest I've found is this discussion but I have zero idea what the solution means, I know Unity not Blazor.
https://discussions.unity.com/t/unity-built-for-webgl-embedded-into-a-blazor-application-wont-instantiate-properly/730703
Is there an ETA on when WebGPU will come out from experimental? And is there a roadmap that provides info on what would be a prerequisite for it to graduate from experimental?
Did you check what path it's trying to load these files from and whether it seems correct?
Seems relevant: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-9.0
I'll have to check it tomorrow, once I'm back at my work computer. I put the files in wwwroot and the paths all seem correct, but going to that path is giving me a 404
I don't have access to it at the moment to confirm that, so I'll double check tomorrow to confirm, I might have just made a mistake somewhere with the pathing
I would seek some sort of output of what files are ending up on the server and where they are.
hey, that's a question I just created. didn't re-write it to void spam. would appreciate help on this ๐
I recall multiple people talking about this 500MB barrier on iOS Safari.
On here: <#๐โweb message>
Screenshot from Web Game Dev discord.
i just made a test project at https://gameserver.crownchaser.com/testtool/ where it even crashes at 280MB if I open another app and come back to this.
oh let me add this to the Discussion topic too
I can imagine Safari becoming even more aggressive if it ever goes to background
after the first crash all hell breaks loose
summary: it falls in a reloading loop. game loads, reloads, loads, reloads
that makes sense, but on Android and Windows, all browser swap the memory instead of just causing a crash or a reload in the app.
i haven't seen similar issue on any other device than iOS
i partly think it might be a config issue
suspect this as well
will test with it as 1GB
Maybe other people have some tips. The aggressiveness does seem unique to iOS.
the hell loop is unique to Safari alone. it doesn't reproduce on iOS/Chrome
changed the player settings' memory alloc settings to start from 1000MB and incrase with up to 1000MB at a time with a 1:1 ratio. that seems to have increased the crash/reload threshold to ~880MB :|
ok now with the new player settings, the actual game runs fine too... so all this time it wasn't the 500MB mem limit, it's the allocation strategy that hit a limit that it had internally set for itself
here's the settings. in case any future webgl dev needed it
Okay, this gave me the reason why it isn't loading, but I'm still not sure the solution. It looks like the Blazor app doesn't load any unknown filetypes unless you specify what they are supposed to be. The js is loading fine, but all of the br files are not. What is the mimeType for data.br and wasm.br? framework.js.br is presumably, text/javascript but what about the other two?
This is so unbelievably close to solving it but I have no idea what they're calling MapWhen on. They didn't include full code so I don't know what object actually has that. Searching for Blazor MapWhen isn't giving me anything specific either
https://discussions.unity.com/t/blazor-server-app-cant-get-brotli-compressed-webgl-build-running/909081
Oh, hang on, I think I found it, making progress...
Woohoo indeed!
hey, how can I run my unity project on my own website without loading Unity Play?
Compile the project to WebGL, upload to website
I have published and build the project using WebGL, but I don't know how to proceed further
I've tried adding the embedded code i.e. the iframe through the webpage but it loads the Unity Play page, tried to host the index file on python but it shows the https restrictions
Are you using the WebGL Publisher package? Do not use the package if you want a normal WebGL build.
Documentation for the normal build process https://docs.unity3d.com/6000.1/Documentation/Manual/webgl-gettingstarted.html
hi, sorry to my eng.
I have question for optimizing Simulation in WebGL.
As I Know, WebGL using Unity does not support DOTS (except ECS).
and Multi Threading also.
recently I found some clue for multi threading using Native PlugIn.
And I read Native PlugIn DOCS. docs shared some rendering example project using DirectX renderer.
these solution really faster, efficient than Unity Rendering?
And
Some Company suggest, Use Rust PlugIn at Unity, as MultiThead ECS machine. And Then, they make 10K Object Crowd Simulation In WebGl.
It is really possible..?
You can't just start executing native code simply by someone visiting your website for security reasons. You might be able to hack the browser to do this if you control the machine used to run the browser, but at this point you might as well build and run a native build.
What are you trying to build? What is your bottleneck?
Fastest running solution is always the one that is specifically made for your problem, but that can require a lot of investment.
thank you replying.
if security problem exist, maybe these approach will be wrong...
currently, we make our digital twin platform for goverment.
we make predicting population risk and control using realt-time/ time series data.
Simulating Crowd / Traffic / Shipping will be good point for customers.
so, I trying to rendering many population object as possible as.
my bottleneck simply in my desire for displaying so many objects.
currently, my limitation performance is 40~50 FPS, Draw Call was only about 4000. (each object has 3,000 vertics object.)
I have been running the unity profiler for a webgl build. All the assets highlighted in red are 3rd party assets in my file tree but are not used in any scene. When I inspect with find in scene it returns nothing. How is it possible for objects end up in RAM despite not behind used in any scene?
Tools to debug build size might give a clearer path to how these assets are ending up in a build.
That's a pretty high draw call count. Are these animated objects? You might want to look into alternative ways to animate meshes.
Engine multithreading should work as long as you don't need to embed the build on other sites (CORS reasons).
Hello, I have keep having an interesting but simple issue with my build, I think....
Anyways when I build to web and upload the project I can see everything in the scene on my computers web browser, but for some reason when I pull it up on my mobile phone none of the models show up. I even changed the materials on them to mobile compatible shaders, this did not help, I also checked to see if they were actually in the scene with a dbug log printed to a UI text field. I am not getting any errors. I am using a blank scene with 3 default object in it.
If anyone knows what I could try, the help would be gratefully appreciated.
Web: Mobile:
did you get the UI text on the screen successfully? Have you tried if you can see default objects with default materials? what phone are you using? hat rendering pipeline are you using? What browser are you using?
I can see UI just fine, but it's something with the textures, the objects are not being displayed.
Also using URP, and it's not a bowser issue, I tested it on several and it was only phones that were affected.
I was able to get them working by using other textures than the default ones. But I was hoping I could fix it without using other custom textures, because it just adds more to the process oh well.
" was able to get them working by using other textures than the default ones. " what do you mean by that? are you using some kind of custom made shaders?
I was not before but now I am the standard shaders we not working, but I could not find just mobile shades to use. The ones I am using now are a bit better though. I can do more with them.
In order to debug this problem I would start with step by step approach. It will take time but you will know where exactly problem come from. Start ne project, add one object with default material. See if that works on your phone. Then keep adding your objects one by one, try doing as small steps as possible to find which step exactly causes the problem. You can also try adding your textures or materials that works by default. This way you can confirm if that is texture problem shader problem, project settings problems.
For sure that is defantly the best solution I have for this. This will help a bunch. Thank you for the help.
I'm confused, according to this post https://discussions.unity.com/t/web-build-with-ecs/1548460/5, Unity jobs system doesn't work on the web platform.
But at least with WebGPU + with "Enable Native C/C++ multithreading" enabled, my web build seems to spread across some worker threads?
Although on it's only spread out to 4 worker threads compared to when I'm running it natively. I have a 12600KF (10 cores, 16 threads)
So...jobs sort of technically works? Here's a build with multithreading turned off
Challenge with WASM threading is publishing, as the common security configuration on websites ends up disabling it.
Godot actually had a nice post about it https://godotengine.org/article/progress-report-web-export-in-4-3/
Oh interesting, I'll definitely check if there are issues with different OSs, browsers, and hosting websites, bur honestly, the fact that it's not burst compiled makes it feel a lot less worth it lol
Wait really, does that actually work and you're profiling the browser, not the editor with WebGL build profile active, there?! If so that's very interesting, because I was about to write a load of C++ for some WebGL multithreaded stuff, and want to know if I can actually do C# (interestingly not because I dislike coding in C++, but because I hate CMake...)
Are your jobs burst-ed? Theoretically, the problem with WebGL Multithreading is (as I understand it) the garbage collector. Now, since burst can't create garbage, is it possible that bursted webGL jobs can actually be run on worker threads? If so, that would be amazing... but I can't understand why Unity would have enabled that without announcing something so awesome.
Yup I profiled the app running in Chrome - it didn't burst compile though. You can compare 1st and 2nd screencap for see the difference between running on Chrome vs in editor
Interesting and... surprising... I was sure I did some tests early in Unity 6, and Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobWorkerCount was always 1 in WebGL builds no matter what you did. Running a test now, but on the other hand, I'm not sure how this fits in with the GC in WebGL (which has its own ickyness that it can't run mid-frame, some of our larger loading/init tasks that generate lots of garbage even have await Awaitable.NextFrameAsync() scattered through them to let the GC run, because otherwise on Web it won't and our high water mark is too high...)
Yeah, you're right - Unity now (6000.0.26) reports 5 for Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobWorkerCount in chrome! Which seems amazing, but I can't repro what you're seeing with jobs in parallel because even the simplest IJobParallelFor Dispatch I can do seems to crash with "call stack size exceded" in WebGL. Are you using IJobParallelFor there? Or IJobFor? Any other details to repro a minimal verion of you have?
Sanity check - is your "Enable Native C/C++ multithreading" setting turned on in player settings? Having it turned off will make the job run single thread (see 3rd screencap)
Tested on an empty project with only this behavior. Unity 6000.0.28
Thanks. I'm not currently able to run your test either, going to try a new project, in .28 instead of 6000.0.26.
I've definitely got C++ multithreading on - lots of my embedded C++ plugins fell over when I enabled it because you need to recompile any wasm libs you've built with different flags (which will mean a load of vcpkg / cmake misery...)
WebWorkers
how do I force open my webgl build always in landscape mode
You can't.
Orientation is dependant on the browser
You can request it though on the javascript side https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/lock` - keeping in mind some browsers (Safari for example) will ignore it.
What I usually do is show an overlay on portrait that tells the user they need to rotate their phone
Hey!
On iOS our web game gets reloaded mid-game. Not even opening other tabs or apps. I've made sure the game pre-allocates all the RAM it'll need so there's no sketchy big alloc happening that would make the browser optimize the tab away. Also, game's not that demanding, and I don't get any errors for the reload so it's not a software crash either...
Anyone has any suggestions on where to look?
The issue started happening after we added a ton of new vfx, so VRAM is probably twice more occupied than before, but CPU and RAM wise nothing has changed between the working and the not working versions. Also, the vfx are just using a simple additive texture shader and they're instanced heavily using Unity's particle system.
reference: demo.crownchaser.com (game's entry code is cc-entry-secret)
Some more info that might be helpful
- pre-allocated ram is 1GB , the crash happens on iPhone 14 pro which I believe has 8GB , and the error happens with no other app opened, so at least 4GB free.
- I can't seem to replicate the issue on clean iOS installs on live iOS testing websites (they don't let me install a lot of apps to replicate a busy OS and then close them all to replicate the scenario)
- The crash happens during the demanding scene where all the new vfx are loaded. I've benchmarked the internal allocator (which simulates allocation, but really it's just using the pre-allocated memory internally. It's a Unity feature so it's solid) and the demanding scene tops at around 400MB of ram, nothing too big.
- I have no idea how to benchmark VRAM on web, so I have zero info on that, but if needs be I'll provide some, given it's possible that is, because it may really be a blackbox.
First to be sure, you don't try to use VFX graphs right? As webgl don't actually support that..
Your problem sounds very much one we had. Things that I learned about it:
- pre-allocated ram memory that browser reports don't really matter in this case
- you need to use Unity memory profiling on your game to see how much memory it actually uses
- when you reach about 300-400 mb RAM usage, unity webgl becomes unstable and starts crashing/reloading. This limits is for iPhones 15 and older (android don't have this problem), newer devices don't seem to have it, or the limit is higher.
- other webgl platforms like PlayCanvas do not have this problem. It seems it is something with wasm. if you search you will find a lot o people complaining about it.
So that is my guess what happening to your app. I really suggest to connect Unity profiler and check what exactly happening
@charred briar Yup! I just put a dialog to inform the user to rotate the device. Thanks!
hi. no vfx graph, it's all either shadergraph or raw shaderlab script.
Thanks for the thorough reply! ๐
in our testing, the game uses just above 500MB of memory at max, but also in a benchmark I wrote, the tab could allocate up to around 800MB of ram before the browser killing it. And even then, it would kill it with an error message, not a tab reload. Right now the game tab just straight up reloads, no error, no special logs, nothing. it just reloads ๐ฅฒ
+++ We did have a memory issue and it was pretty much like you desribed. But we solved that before and the game was running fine at <500MB ; the new "reload" problem only started happening after we added a lot of new vfx (which still don't cause the memory to go beyond 500MB, and even if it did, definitely not beyond 800MB. What's more, we preallocate 1000MB anyway so no alloc/dealloc...)
I suspect that as much as this issue is similar to the infamous RAM issue, it might be related to something else, say, VRAM?
I have a webgl 3D game. Im currently on a prev version of unity rather than unity 6.
The problem i have is that if i upgrade it to unity 6 my game crashes on IOS after 11 - 12 rounds. But it doesnt crash on the current version even after 30-40 rounds.
what can be the issue here? if anyone has any idea
Out of interested, how did you solved that issue? It indeed sounds really really like RAM reload and relocate issue we talked, no errors, just reload on iOS. As preallocating more memory did not solve that issue for me, as I told, browser and iOS memory usage are bit different issue.
Coming back to your issue tho, Are you using addressables or something like that? You could test VRAM usage with profiler, set everything to lowest quality and see after reducing usage of VRAM does crashes still happen.
Well, the answer would be profiling. As you have pretty specific crash time zone, so you can test it. At crashing point check what resources are being used, maybe you have memory leak somewhere, and each round keeps loading extra assets or textures over and over again. I haven't personally noticed any crashes with Unity 6 yet, but in your place I would:
a) check quality settings and build settings. As unity 6 added new stuff, they might be automatically enabled and using more resources than usual in older version. And then you hit iOS limits.
b) After upgrading I would delete library folder and start Unity again to rebuild it from scratch. Sometimes it causes weird bugs as old compiled code don't flow with new code.
c) triple check build settings
Is there any errors on crash? you can check logs with chrome://inspect in different tab to see logs you get.
Sure will check that
Same problem haha apparently it's RAM related. Keep it under 500MB. Profile and detect any memory leaks. Use brotli and adjust the server headers to send br for those .unityweb files
I did use brotli
Im using urp as well which causes fps drop on android too
Will look into it
Nothing unity-related, just optimized textures and models.
I checked vram yesterday, it was around 400MB . Also I found a memory leak, fixed it and the issue still persists. (It wasn't a huge leak, just around 100MB over time)
++ on the question of what I use for memory management, I use Resources. I profiled it and it does handle memory properly
after the addition of editor-only serializable fields in Unity 2023, I've found writing my own Resources wrapper is a lot better than using Addressables. You also get all the Editor goodies with exposing editor-only object reference that doesn't get into builds
Do anyone knows if:
- Does new input system support multi touch actions like pinch on WebGL?
- Is there a way to simulate pinch action on editor to test if code works?
- yes, i don't know about touch PCs, but Unity has a feature which lets you test your game on your device right there in the Editor. If you have an Android, checkout "Unity Remote" in playstore
Thanks will try that for temporarry solution. aster than deploying webgl on server checking there.
Ever figure this out?
Fwiw it looks like it's trying to remove shaders and some badly tested unity build code couldn't find it, and errored
You'll have to show the errors
Last I used it it needed you to upload a zip to them, no compression done (so no brotli)
If you're sure you've checked all the basics fixes, it's time for checking logs on the website. In most browsers you can open the debug panel by pressing F12
It's crazy cause after writing that message I went back and tried playing it and it worked. Then I exported the game again after fixing some bugs with the same settings and it doesn't work again. I decided to just upload to Unity Play and link it on the itch page. I'll check the debug panel sometime later though, thanks
what can I do about webGL having pink shaders?
its a certain asset pakc that isnt rendering shaders
how do I force it to do so
it also doesnt seem to have rendered any lighting or fog
well it depends on shaders and where you got them. you have choices:
- you convert the shaders to default shaders if possible. you lose something but at least it works:
- you open shader code and try find what is bad and fix it your self.
- you text a nice message to shaders creator and ask him to update to work on webgl.
who knows what features e is using for those shaders. If he using anything with compute shaders, you are out of luck. or any other thing from long list webgl doesnt have.
pain and suffering
thank you for the response
see if it would render
I was gonna try to do this
yes it is sadly. For advvantages wbgl have, it have its deal with disadvantages.
if you do not use addressables or other resource management tools, than all shaders should be included in build automatically.
I dont
idk, ill try it cuz im desperate to not have to use default shaders
but if it comes down to it I will
thank you v much for your help
I'd dig for errors like I've mentioned before. It'll probably tell you what operation the shader did and why it failed usually
like incorrectly sampling depth, ect
could it be any of those?
idk how to read this stuff very well honestly
I didnt program anything about the game
I was the artist :^)
is this it?
sorry for the ping
note: I using URP
HDRDebugView I doubt is your shader
What shader are you using for your skybox?
Unity 2022.3.37f1 - Im getting a "memory access out of bounds" error on my webgl build when running on the browser. The first time I load the app, everything works fine, but when I hit refresh, and load the website again, it crashes with that error message. It crashes in the middle of loading unity. I've tried doing a clean build, and same thing happens again (first load works, subsequent crashes)
Uncaught RuntimeError: memory access out of bounds
at il2cpp::vm::MetadataCache::Initialize(fishbait-web/) (http://localhost:3000/fishbait-web/Build/fishbait-web.wasm.gz)
at dynCall_i (fishbait-web.wasm.gz:0x71f7654)
at Module.dynCall_i (fishbait-web.framework.js.gz:4301:372313)
I always mixing memory out of bounds errors, which is which.
As one is caused when you try to access array element that does not exists.
And another one is when you actually just run out of memory. Have you profiled your project how much memory it uses on WebGL and PC? Maybe you set too little starting memory on build settings (idk if those options are on 2022 or only starts from 2023).
You say it fails on reload. Does it fail on load even if full refresh with disabled cache ? Do you cache anything or read anyting from cache?
The initial memory size is 32, and maximum memory size is 2048 according to the publishing settings. I use PlayerPrefs to store player settings like username, etc. So I think maybe thats the one being stored in cache
Does full reload without cache also gives this error? It could be in theory: first load reads cache for playerprefs, it dosnt exists, loads the game. Then you save playerprefs in bad way, so when for second time it tries to load them as you already saved and thy exist already but with incorrect data, it gives you error. Tha is my theory one ๐
or you somehow store more than 1 mb of data. Like try storing images or something.
So After, deleting the cache storage via the chrome devtools, the error went away. and it no longer crashes even after refreshing
Maybe old cache was playing with your new build. I guess.. Yey?....
yeah maybe..two of the entries got removed, when i reloaded. before there were 4 entries in the cache storage, now there are just 2. Glad that it worked. Thanks!
For cache issue, just return; on the first line of ServiceWorker.js , the cache works perfectly that way
I'm not very familiar with ServiceWorker but make no mistake Unity's caching is done internally not through serviceWorker or other standard solutions
https://stackoverflow.com/questions/79246791/ios-browsers-reload-webgl-games-built-with-unity-on-big-loading-events-that-do
I had fixed the issue for iPhone 14 pro by removing all CancellationToken from the game and giving breaks for loadings. Now it's appearing on iPhone 14 pro max
Any idea?
game url
-# cc-entry-secret
what do you mean giving breaks or loading/
Suddenly page reloads
hi im new!
Finished my first Unity project! Play the game on your desktop browser and leave any notes for me
One thing I find weird is that there is supposed to be text on the top left keeping track of your score. It's not on the web version, but on the computer version
Hi, how do I open another Android app or iOS app from Unity WebGL??
I would change this question to: how do I open another Android app or iOS app from JavaScript. Which will return you a lot of methods on google. And then from unity just call that JS script. As I am not aware of any methods to opening applications directly from Unity WebGL.
Congrats!!!
The text not appearing is probably an issue with your canvas scaling setup. You have to set the canvas scaler to scale with screen size and set the UI element anchors correctly.
how do i get if app is in background or out of focus for webgl on native devices?
once again, use JS and send message to unity;
document.addEventListener("visibilitychange", function () {
if (document.hidden) {
// App is in the background or tab is inactive
SendMessage("GameManager", "OnAppBackground", "background");
} else {
// App is in the foreground or tab is active
SendMessage("GameManager", "OnAppBackground", "foreground");
}
});
window.addEventListener("blur", function () {
SendMessage("GameManager", "OnAppFocus", "lost");
});
window.addEventListener("focus", function () {
SendMessage("GameManager", "OnAppFocus", "gained");
});
Examples
I did try this it didnt work for me. My webgl game is hosted on discord as a discord activity
Sorry I am not familiar with discord API and how its handles events like these.
No problem thanks.
Hey guys, I've been struggling with this for a while, and I don't know where to ask. So i've made a chatgpt wrapper using unity and tried to export it to WebGl, but I keep getting a webassembly error. I'm pretty sure I can find another way to do the wrapper. I'm just wondering what went wrong and why it's broken, anyways it works fine and is able to be build in Windows.
How are you connecting to the API? You need to use Unity's HTTP API or go through JS yourself to get networking.
I believe CORS errors would be more explicit than this
huh
This could also be caused by some AOT limitation https://docs.unity3d.com/6000.0/Documentation/Manual/scripting-restrictions.html
hey guys, I'm working on a project as a complete beginner. I'm trying to build a webAR service for which I'm facing a lot of issues in XR plugins and to integrate AR part in the unity
can someone personally connect over and guide me with the same, it would be really helpful for me. thanks in advance!
My project uses webGL 2.0 and photon PUN2
I have performance issues (~25fps or so) so i'm trying to enable multithreading however i'm getting these issues when i start trying to connect to the photon server.
Any ideas why this is happening, thanks in advance? Unless I'm just dumb in thining that turning on multithreading will magically fix performance issues. I also tried webGPU but that gave no significant increase in performance
excuse me guys, does anyone ever had problems on UI buttons lagging or input lagging from webgl build?
my game runs smoothly but the UI inputs kinda lag escpecially when pressing TMP buttons
Because WebGL does not support multithreading. It support only C++ code multithreading, which means no C# multithreading. No jobs and etc. To be clear, you can use some features, but mostly you can't. you migt want to connect you profiler and see is it GPU or CPU that is bottle necking your project and try to optimize there.
never seen that kind of behavior sorry. What kind of webgl input are you using? https://github.com/kou-yeung/WebGLInput ?
Ohhh ok thanks ๐
What i ment was the new input system manager
I have a mobile controller using the new input manager system, the reaction time whenever the user pushes a button or move swipe the screen is slow
There's a significant delay
How do i profile in mobile browser's?
Depends on your unity version. But normally in build settings you choose developer build, then there will be extra option stating: autoconnect profiler.
then press build and run. Then you will see all logs on editor from your webgl, and can use all other debuging tools.
As from what I worked with input system swipes and touches did not have any delay. It might be some setup problems? Do you have any Procesors on your inputs?
Maybe it is a code problem, like you do something in Update function to trigger events in a bad way. Could you give example of code how you are using it? Are you using c# events? unity events? Sending messages?
Its quite complex, I use a game from asset store. Its never ment for mobile, but I tried to port it to mobile inputs. Mind if I dm you? I probably send the detail later
Any hope to find clues why WebGL on a specific Android device just gives you black screen if you touch it?
More modern Andoids seems to be fine...
Doesn't have to be a button, just any place on a screen
Before that point, max 60 fps and everything is ok
I have heard that specific mobile game issues are basically discarded cause it's too annoying and specific to get to the root, sadly...
And it's getting even worse if we start talking about browsers and WebGL I guess
it sounds indeed like something difficult to solve. Especially as new devices seems fine. Most commonly the issues with different devices comes to:
A) less resources, for example not enough RAM.
B) Racing conditions. On fast device task A always completes before task B, but on slow devices that can be different.
C) hardware incapability.
First of all, when you open browser console, do you see any errors and warnings? You can connect your android to PC and have for example chrome console connect to your device and see logs in real time.
Second, have you tried building in develop mode and see if there is any differences?
Third I would suggest connect profiler and see more precisely, but on android it will be harder. So instead try running memory profiler on your webgl version on pc, and tell me the how much memory does your game eats.
Last one is a long shot, is your background is black maybe by default? As there are some instances when touch on webgl returns values that is very unexpected. For example you epect values between -1 and 1 yet webgl returns you 124 or -800 or something. That can cause errors in your code or send camera really really far away somewhere and it just looks black. I suggest have FPS meter always running to see if game froze it self.
Seeya Later I hope that will give you clues to this weird problem.
While i m building WebGL the site opening but the game is not, it is being white screen and console writes me "saving has no effect. your class 'unityeditor.webgl.httpservereditorwrapper' is missing the filepathattribute. use this attribute to specify where to save your scriptablesingleton. only call save() and use this attribute if you want your state to survive between sessions of unity. unityeditor.buildplayerwindow:buildplayerandrun ()" i m searching this everywhere but couldn't solve it
Can you recreate that in an emulator to see if android version has anything to do with it
I tried for windows and dont have any problem with it
Should i go for Android?
Actually i m new for unity and this project came to me , i didnt make this and i m trying to solve this problem cause i need to make this project WebGL
Hmmm interesting, what network stuff does it do
Normally i m making games in different editor
What do you mean
Btw they sent me with api , api and project folder
So i need to solve this error
Like does it just call http requests or is it doing something with websockets or something more?
http requests
this is the screen i get in site
this is the error i get
and still couldnt solve it
Oh interesting what is this ScriptableSingleton
You have the project
Visual studio?
And i tried to change unity version as well
But same error always
and the other error this as well so i m completly stuck
but exe is working ๐
so how can i solve this , anyone ?
is there any reference to this getInternalformatParameter in the code?
also what are your webgl build settings
how are you serving it
it is default
i guess you can just open the index.html lol
searched it and none
should i open this in firefox html ? or building ?
your VS has the full project solution open right
open the webgl build html in firefox
does firefox open the webgl?
yep it did
what part?
seems like not
latest firefox version? what is your videocard?
gtx 1050
but videocard is not the problem
i tried in 4060 ti as well
same error
well of course
that's normal
this is build
most of it is editor cache
i have a small 2D game which at one point had a 20GB project folder
oh i tried to clean and rebuild again
nah that wouldn't help
nah those kinds of fixes are for extremely specific problems
in the webgl build?
but my project is literally just empty scenes with code generating UI for each scene
oh
well still i didnt change any building setting
can you help me if it is okay
this is default i guess
try to see if disabled compression changes anything
tried it
i couldn't get either brotli or gzip to work for the life of me
๐ but let me try again
but it usually shows if that is the problem
before try that should i delete the one i builded
you can but it should overwrite
so it can work if it is on build ?
wdym
should i write on this
or should i build in different folder
keep in mind i can't do much without access to the project itself : D
doesn't really matter
unless you want to keep the old build
you can try development build
to see if it changes anything (unlikely but worth a try?)
then it connects to api
no problem
development builds usually build quickly and run poorly because they donh't implement various optimizations under the hood
but what if i dont make them connect?
cause i didnt
cause i dont know how to connect api and unity :d
think of unity as a frontend application
for example
{
_messageLabel.text = "Logging in...";
var url = $"{Globals.AuthServer}/api/auth/login";
var loginRequest = new LoginRequest
{
username = username,
password = password
};
var jsonData = JsonUtility.ToJson(loginRequest);
var request = HttpClient.CreatePost(url, jsonData);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest();
if (request.result is UnityWebRequest.Result.ConnectionError or UnityWebRequest.Result.ProtocolError)
{
_messageLabel.text = "Error: " + request.result + "\n" + request.error;
if (!request.error.Contains("404")) yield break;
_showRegistration = true;
Generate();
}
else
{
var loginResponse = JsonUtility.FromJson<LoginResponse>(request.downloadHandler.text);
if (!string.IsNullOrEmpty(loginResponse.token))
{
PlayerPrefs.SetString(Globals.AuthTokenColumn, loginResponse.token);
PlayerPrefs.Save();
_messageLabel.text = "Login successful!";
StartCoroutine(FetchUserInfo());
}
else
{
_messageLabel.text = "Login failed: Invalid credentials.";
}
}
}
I have this login method, it simply calls my Auth API
i have this httpclient wrapper for unitywebrequests to add auth token to each of my api calls:
string method = UnityWebRequest.kHttpVerbGET)
{
var request = new UnityWebRequest(url, method)
{
downloadHandler = new DownloadHandlerBuffer(),
};
var authToken = PlayerPrefs.GetString(Globals.AuthTokenColumn);
if (!string.IsNullOrEmpty(authToken))
{
request.SetRequestHeader("Authorization", "Bearer " + authToken);
}
return request;
}
public static UnityWebRequest CreatePost(string url, string jsonData)
{
var request = Create(url, UnityWebRequest.kHttpVerbPOST);
var bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonData);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.SetRequestHeader("Content-Type", "application/json");
return request;
}
so it's really all in the code
it should already exist in the code of your unity project
if it has any form of api integration
search for new UnityWebRequest
well i did but that api i couldnt make that work
well i opened api in visual studio
and started .d
and then i tried to add to unity project
i did but still couldnt connect it
api there but
i wonder if it is working .d
no you don't need to add the api project to the unity solution
the api is a separate application
running on some server
yes i tried that as well
you have both the unity project and the api of the game?
so basically the entire source code?
yes
entire source code on my hand but i couldnt build for webgl .d
funny right ๐
i mean
how long have you worked with unity
and how long have you worked with webdev
3 days for unity 1 day for web dev ๐ but 4 years for ue
but i need to make this happen i have no other way
and i have 3 days so i searched everywhere over internet
probably nothing in ue you did had anything to do with online integration
yes exactly
don't be so hard on yourself
you are basically a junior for this stuff even if you have good logic crunching skill from ue
alright so your task is to make a unity project work on webgl yes?
yes
so what you need is a build that functions in webgl just as it would in say android or windows builds
yes exactly
i m doing actually
ok you know git, good
I agree on that, WebGL is nasty beast. It have a lot of caviats that dont work on it.
I would suggest you to start debuging step by step. First create new scene and include only new scene in a abuild. it can be emty scene. Build and run, see if that runs. This would show if your project settings or template is incorrect. After that you can work with searching other things.
i will not mix them
do not mix them
also you don't need the api for this step
you just won't be able to log in or whatever
we'll worry about that later
okay
ooooh this is good advice
i tried it
and that runs
But yeah webgl is %#]!ยฅ<
but this project doesnt
No no
Create a new scene in this broken project
And in build settings enable only that new scene
okay give me a sec waiting for opening
alright
should i delete the main scene in build settings??
or just disable?
Disable for now
okay
All of em except the new one
Only one scene?
yess one scene but many things
i guess that's doable
hmm, that gives me an idea to remake my project to be single scene
i already generate ui purely via code
๐
nah I mean this would be kinda like a single page application
btw should i connect project to cloud ?
well i event tried that as well
i opened git cloud in vs and didnt work as well ๐
waiting still
it wil open in 5 min
Well i liked unity after if we can solve this i will start learning unity from bottom
New challanges needed
for this you need to run build and run. Rather than opening index html. At least in chrome. you need to disable some flags in order to load it otherwise. I think same goes for firefox, you need change settings to support it.
yeah tbh i had a bunch of settings changed in firefox so mine isn't the default
tried that as well
and that was long enough ago i don't remember any of that
opened switching platform
i tried everything over internet
before ask anyone
here is my last hope
I jsut trying to catch up and adding some extra info. Also you might want to try building developer version and connect profiler to it, so you could see more precise which code causes the problem, if it that is the code problem.
i tried different build settings etc.
You said it uses API and was build not as webgl target platform. Are you sure there is not websockets code or other WebGL not supported code? Or multithreading like Jobs and etc. DOn't mind I am just firing blindly while waiting for emty scene build results ๐
well there is leaderboard in this game
๐ค
So next thing you can try after testing emty scene. Disable some game objects that have features you can modulary disable. Try if that works on editor. Then build it. And then enable one by one and see where it will break. That will take tons of time, so make sure to build in developer mode to make it faster.
i need to quickly implement something with websockets
you will need to use UnityWebrequests or simple websocket package, the sockets.io doesnt work on weblg.
oh you have adressables in your project.... you know how to use them riiiight?
I already use UnityWebRequests for https
so in short. Adressables makes your game assets in to packages. sort of. So everytime you change something, depending on your settings, you need to rebuild addressables before building game project it self, otherwise changes will not be there. so make sure to build addressables before building project.
seems nice ๐
yes. and everytime you change anything that is included in addressables you need to rebuild addressables before build.
well i didnt change anything except adding new scene ๐
rn
i see i just checked how to build addressables i didnt try that , maybe before i build i should build addressables
okay i builded addressables
and now building new scene lets see
what will happen
maybe i should have gone with main scene
๐ค
it is like this btw ๐ค
idk anything about this ๐
everything in here ๐ yes the problem is this
i m pretty sure problem is this one
but lets see
what is in Build In Data. As here it seems only localisation, which should not effect anything too much.
well all game in here actually
localization , what is that ? is it different thing ?
localization is basically what allows multi language support
localisation mean it will choose different code, mostly text for different locations. Like in tukey it will be turkish, in spain spanish and etc.
localization assets are usually just a bunch of strings in different languages
hell yeah
maybe 5 minutes more ๐
damn
now 3 more min
what cpu
i7 7700 ๐
damn
man it's almost 8
but still working ue5
alright new scene is working
and error is still here btw ๐
good. Time to disable everything and build alot of times enable thigns one by one. Dont forget to build as developer mode o make it faster. and change build type for build speed
damn i ran a build for my project with shorter build time
took a bit under 1min 30s
but remember my project is literally just six scenes like this
it's in its early stages and i have to set up a lot of ui
a bit under 1200 lines of cs code
Optimized
have you tried UI toolkit. If you like handleling UI via code that is kinda nice addition to UI. Need to learn a lot at the begining, but later is quite fun.
UI toolkit is exactly why I'm doing purely code UI
๐ค
check out my helper methods
i dont even know where you find that icons ๐
(yes, I know I can use uss, I use it too)
yeah i'd say about now i'm finally feeling comfortable with it
had a few good days with it
oh shoot
unchecking it will disable it.
okay it is easier
i'm now at the point where i can write ui elements (like for example a slider + text) from start to finish without once checking how it looks and it comes out exactly as i wanted it
definitely not at any advanced level where i can make crazy geometry with uss
I really like UI toolkit because of how easy stuff like this is
my game will be very heavily based around UI for interaction so I'm pretty pumped having finally somewhat grasped it
ngl it was tough at first because I tried to do with via the ui builder rather than code first/code only
it was such a pain fiddling around with the ui builder
ah but this is better for #๐งฐโui-toolkit my bad
okay started to disable everything
lets see if it works
that means while everything disable it works right ?
๐
thats good news. now you just enable one by one and see where it stips working ๐
niiiiiiiiiiicce
easy
so it was just addressables huh
i can totally believe that
very typical
everythin enable except 1 thing
and working
๐
windmill
the model
this one how can be possible
did you redo the addressables build
no no no addressables build
i didnt do anything with it actully
should i search this mindmill in vs ?
welcome to webgl. when you do nothing and it works, and when you do nothing and it doesnt work ๐
๐ you are welcome
first try running it with it enabled to be 100% sure it is its problem
well how can i solve that
there are 3 lod here
probably problem is here
lets see
trying without it
then there is no problem with code
the problem was lightning always
so the problem is exact this one how can i solve this
i cant believe that was the problem all the time
so okay we solved this but how can i connect api
there are requests
but i think thats enough for today i will research for that
still thank you so much guys both of you
๐
API connection is literally just UnityWebRequests POST and GET requests. Just as our friend showed before ๐ you might need to work with CORS settings and etc, but that is for laters.
well i dont have much time actually
and there are codes already written and ready
i just dont know how to activate api ๐
cause as i said it was working in exe
so it has to be connected right ?
it depends on how you API is created. And how you connect. Some API establishes connection and keeps it. others just sends information when needed. I can't answer this question for you without seeing code.
It is sending information when needed
have you confirmed it sends data with logs? does error handling states that anything goes bad? No logs? Are you using unity web requests?
let me send you the codes that use httprequest
this is my api opened one @astral wave
i thought this means sending information
and login not working