#🌐┃web
1 messages · Page 2 of 1
Probably not, it would load them all, and trigger their colliders to do a physics check. My experience is that collision check is actually way more of a performance hit than anythibg.
It will definitely improve the FPS in most cases though
Technically it would probably have a very small speed up when the scene goes live. But like 10ms at most kind of thing
Ooh I see thank you so much for the explanation
You bet! Thank you for the thank you 🙂
it will help in 90% of cases. As long you camera moves and you have something that you dont need to see, it is a a performance boost. Expecially with terrain or indoor enviroments.
it make your project just a bit bigger tho 😄
does anyone know why unity 2021 seems to have so many issues when pushing webGL. I have some UI that got so sluggish when I introduced a new model in the scene, this model is way less complex then the one it replaced but somehow the UI framerate dropped in half! I tried to rule out the model by even stripping it down to nothing but a little part of the model thats like 100 verts and with a mobile shader. Finally I put it in unity 2019 and its fine
what am i doing wrong? is 2021 just shit
2022 same issue by the way
How do I play a video in a UnityPlay WebGL build?
videoPanel.GetComponentInChildren<VideoPlayer>().url = "test.mp4";
videoPanel.GetComponentInChildren<VideoPlayer>().Play();
I am using this in code to get the video. It works when I play it in the editor but not when its up on UnityPlay
I am hosting the video in github pages
Is there something special I should be doing?
*also the "test.mp4" is not the real "https...test.mp4" url I am using
ok now what is the best lighting approach for webgl,
it's completely different than what it looks on the editor
I thought 2022 is the best, since they have memory limiter
video doesnt seem to work on webgl using the standard video API provided by unity eh, Im using this -->. https://assetstore.unity.com/packages/tools/video/video-player-webgl-192420and so far my demo scenes work so hopefully i can switch to this just for webgl builds
i dont know man it seems so flaky on webgl , 2019 has no issues. My issue now is so far contained to Chrome on a mac , my m1 and other m1s so far
oddly enough even chrome on a pc is. fine
I felt way more insecure about it from day one and further T_T
anyway please drop me some tutorial for webgl lighting @halcyon pier
for webgl 2022 newest version is pretty much a must. too many bugs was fixed. and features added that will not be backported to older versions. In your place instead I would build Dev build, autoconnect profiler and see EXACTLY what is causing your problem. Maybe you redrawing UI too many times, maybe Update function is gettings stuck somewhere. Tons of things can go wrong.
Welcome to webgl. You can play stuff if it is not in your domain. Like youtube and etc. Security stuff. If you load the url from your streaming assets you wont have any problems. But you need to setup link correctly, in most cases full link unless stated differently.
https://thehostyourwebglisat.com/StreamingAssets/test.mp4
and put it in your streamign assets. that is simpliest way. otherwise you will have tons of funsies 😄
but it wouldn't work on online webgl platform like itch & simmer
anyway do you know how to make WebGL lighting appears like lighting at editor
do we need bake them first ?
tutorial link please
have fun reading it 🙂
It depends on your pipeline, and if lights are real time or baked or mixed.
or take minute of your life with this
https://www.youtube.com/watch?v=NOv31HSqs6U&ab_channel=HIYU
Have in mind HDRP will not work on WebGL and you cannot make it in same way ever ever ever.
it would work, as you still deploy your WebGL project on web server, and streaming assets is just one of folders that are by default accesible by webgl. Unless ichio dont have control over it. but I doupt it. idk tbh
thanks man this is gold, but are you sure it will be looks similiar on web gl ?
e.g there is shadows appear on my editor, but once I build it to WebGL,
realtime shadow didn't appear at all
most likely becayse on webgl and editor default quality settings are not the same
this is mine, so it is all the same. but by default, pc is higher options and etc.
What is the downside of using data caching in unity webgl?
If you will update your build people who downloaded it once before might not see differences. Offcourse that depends on your webserver setup as well.
Ooh I see that's why sometime user need to clear cache to get the latest update
Okk thankss
hi, has anyone had problems with shaders on webgl?
I have few objects on shaders
when built its not visible 🙂
Hello
can use Probuilder of Unity for my commercial project?
im confused... please Help me out...
yes you can use probuilder for commercial project. As it just lets you build 3D models.... It is same as using blender on any other asset. As long as you are selling it as a game and not a tool
oh also, does additive materails / shaders etc work in webgl?
There are so many problems with shaders I cant count 😄
If it is vfx graph, it does not work with webgl and will never will.
If you using shader graph, please be sure to include your shaders in build.
Thanks you for answer, its a shame it does not work too good 😄
well...Probuilder of unity has some third party licences notice.....
here it is
thats why i was confused...
if i can use Probuilder of unity for my commercial project or not.
please take some times...and just answer me 🙏
Have you read the licences? I don't see any part that talks about distributing things made with the software, only about distributing the software itself
well, Im just using the ProBuilder tool , not selling this tool itself ...so ,in that case , I can use that ProBuilder of unity in my commercial project , isnt it?
I expect so, but you can verify that by reading the licences you linked
I can't make promises about what the licences say when I don't have the time and interest to go through them
all the license types are MIT except one ...which is 3- Clause BSD
so, in that case ...do i have to attach those licenses in my release to obey the terms and conditions?
Only if you release ProBuilder along with your game for some reason 🤔
if my release only just includes gameobjects or something modified by ProBuilder ...then do i need to attach those notices?
Worth noting that ProBuilder supports runtime use. This isn't really a #🌐┃web topic though #💻┃unity-talk
your link doesn't work
If you remove the "and" at the end, it will
oh yeah I'm so dumb XD
wait I need some pdf or some file to be able get downloaded from webgl
directly, can't find decent tutorial tho
Y'all
Can anyone tell me more about this ?
Downloading some files is required on my WebGL game
wether it's a pdf or image
A tutorial would be helpful
Any gurus around can give me a hand
got the following jslib function
defined my method like this on the C# side
fails to compile
how is the signature not matching?
I am extremely confused here
if I remove the extension parameter it does work
why is the compiler giving me bs for adding a new parameter to the function?
like, for reals, wasm is saying this is the line with error
public void UploadMIDIFile()
{
UploadFile(gameObject.name, "ParseMidi", ".mid");
}
[DllImport("__Internal")]
private static extern void UploadFile(string gameObjectName, string methodName, string fileExtension);
var UploadFilePlugin = {
UploadFile: function(gameObjectName, methodName, fileExtension) {
var gameObject = UTF8ToString(gameObjectName);
var method = UTF8ToString(methodName);
var fileExt = UTF8ToString(fileExtension);
var unitycanvas = document.getElementById('unity-canvas');
if(!document.getElementById('UploadFileInput'))
{
var fileInput = document.createElement('input');
fileInput.setAttribute('type', 'file');
fileInput.setAttribute('id', 'UploadFileInput');
fileInput.setAttribute('accept', fileExt);
fileInput.style.visibility = 'hidden';
fileInput.style.display = 'none';
fileInput.onclick = function (event)
{
this.value = null;
//make sure all listener are removed even if you cancel the dialog
var element = document.getElementById('UploadFileInput');
element.parentNode.removeChild(element);
};
fileInput.onchange = function (event)
{
if(event.target.value != null){
SendMessage(gameObject, method, URL.createObjectURL(event.target.files[0]));
}
};
document.body.appendChild(fileInput);
fileInput.setAttribute('class', 'focused');
fileInput.click();
fileInput.setAttribute('class', 'nonfocused');
}
}
};
mergeInto(LibraryManager.library, UploadFilePlugin);
Dealing with this JS non sense is taking away years of my life
lmao
I was in fact, correct, the signatures do match, but Unity being terrible once again for some reason has the file cached somewhere
fixed it by making it a new function with a different name
thanks Unity, love you
Been trying to figure out for a while now how to get player prefs to transfer between updates
Using itch.io
I know the data still exists somewhere but I can’t figure out how to access it from the new updated build
Found this a bit ago, but can’t seem to get it to work
Hi there! I'm currently developing my game (with Unity) and for easy testing I am creating webGL builds to put on my page. Between sessions, I need to store the audio settings and highscore of the pla
In some setups there are issues with filesystem giving you a new path after each update. The solution to this is to use a fixed path, but I don't think we can control that with PlayerPrefs. You can work around this by writing your changes to a file at a fixed position in the IndexedDB instead of using PlayerPrefs.
Damn, I wonder if someone has made a unity package to do that yet
Well Unity ships with multiple serializers and regular file IO works
Newer versions have newtonsoft JSON, but original JsonUtility can also be used
I’ll try and search around for a premade solution, most of this conversation is going over my head 😅
Most game saving tutorials that don't use player prefs go over these things
Instead of one of the JSON serializers, you might see BinaryFormatter instead.
@sweet oriole I found a tutorial and followed it
I tried using System.IO.File
it worked in the editor but it doesn't work in webgl
Like, it doesn't even save between sessions of the same build
For this you need to make sure you do the filesystem JS sync thing
So just add
[DllImport("__Internal")]
private static extern void JS_FileSystem_Sync();
To my script, and call it on start?
Call it whenever you have written to the filesystem
Worth noting that your snippet I believe relies on Unity already shipping that JS method, which may or may not be present or called the same in your Unity version, but it's worth a shot. If you see related errors later, you can just include a certain JS script into your project to address it
Do I also call it before I access the data for the first time on start?
You shouldn't need to.
Would this work?
Yes
@sweet oriole Works inbetween sessions now, but not inbetween builds
What path you are using? You might need to make sure it's fixed
var fullPath = Path.Combine(Application.persistentDataPath, a_FileName);
Not code I wrote myself, but I think that's the path
Print the Application.persistentDataPath value in your WebGL build and put it in your code
You are probably going find a pretty random looking string of numbers and letters in it, which you should be able to replace with something prettier if you want.
Just do Debug.Log(Application.persistentDataPath);?
Yea
Ok, so it was /idbfs/034ce56c07271c4f51364fd8d201959a
And I did fullPath = Path.Combine("/idbfs/DeckBuilder", a_FileName);
It's building now, so i guess we'll find out if it worked
I tried changing /idbfs/034ce56c07271c4f51364fd8d201959a to /idbfs/DeckBuilder, but it didn't work
Anything in browser console?
I couldn't get the browser console working
I ended up making the path display on the screen
Wait, do I just use inspect element
Whoops
Yea talking about the browser console 😄
Failed to read from /idbfs/DeckBuilder/SaveData.dat with exception System.IO.DirectoryNotFoundException: Could not find a part of the path "/idbfs/DeckBuilder/SaveData.dat".
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0
Failed to write to /idbfs/DeckBuilder/SaveData.dat with exception System.IO.DirectoryNotFoundException: Could not find a part of the path "/idbfs/DeckBuilder/SaveData.dat".
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0
How are you writing/reading it? Might need to make sure you are doing it in a mode that handles part of the directory being missing
public static bool WriteToFile(string a_FileName, string a_FileContents)
{
string fullPath = FullPath(a_FileName);
try
{
File.WriteAllText(fullPath, a_FileContents);
return true;
}
catch (Exception e)
{
Debug.LogError($"Failed to write to {fullPath} with exception {e}");
return false;
}
}
I guess I need to create the /idbfs/DeckBuilder folder first?
Most likely. Pretty sure there are methods in System.IO that should handle this for you, but I can't recall them
In WebGL the path is passed through md5, that's why you can't recognize your directory name.
Found a fourm that mentioned this ^
Can you link it?
They use Directory.CreateDirectory("idbfs/abcdef");, but it didn't work for them
The md5 commend seems to just refer to why Application.persistentDataPath looks weird
WebGL: Application.persistentDataPath points to /idbfs/<md5 hash of data path> where the data path is the URL stripped of everything including and after the last '/' before any '?' components.
Try doing the Directory.CreateDirectory and writing to it to see what happens
IT WORKS!!!
It also works between builds now :)
Thanks a lot for your help!
I need help plz
I'm using the new input system. My controller works just fine in the Unity editor, also if I export my game to desktop. But when I export my game to webGL the right thumb stick doesn't move vertically at all.
It's just that one axis, horizontally it still works.
I've tried everything I can think of, searched the entire internet and found nothing.
Hi, can I differentiate between Touch and Mouse on WegGL Builds? Even use multitouch?
yesterday i started this simply airhockey game (from a tutorial with some improvements):
https://stuepfnick.macbay.net/airhockey2d/
And for control on Computer with mouse it shouldn't be needed to hold down the mousebutton. But on touch devices this would make it possible to jump between position, which is already possible when using multiple fingers - as it gets the average then.
So it would need real multitouch detection and follow just one finger - and also it would be possible to have 2 players on 1 device then
Hi guys just want to ask about webgl build, so I created a webgl game and everything is fine when I'm using a web browser in a computer, but when I use a mobile browser everything is ruined since it's running in portrait mode, is there a way to make it force run in landscape mode when playing in a mobile web browser?
There is. But you will need at least one click of the user to do so. Automatically sadly it is not possible.
you can easily Rotate automatically screen if game mode is full screen. yet to make it full screen you need user to click on screen at least once. Otherwise due security reasons you wont be able to make it 😄
How do I make it turn to fullscreen with a click, since when its running on mobile web browser the fullscreen button at the buttom disappears.
you will need to write your own. Mostly Javascript to go full screen in browser mode. And then trigger event on unity to rotate or something like that. If you will google this question you will find 3 common solutions. But all of them will include needing Javascript or html5 manifest editing.
But the fullscreen will fix the orientation of the button and objects since it doesnt scale with the screen right now
is it possible to use 2 on-screen joysticks in webgl mobile?
by default it looks like one of the joysticks is stuck when other is in use
same applies to the buttons
hi ,did you find a solution for this?
I have same problem too, multi tocuh does not work properly on webgl
i wonder if there is a bug report for that issue or not
you using s3?
i am uploading my Project on GitHub and my Build is continuously failing can someone help me with that?
Hi everyone, i have a serious and very problematic question: I 'm currently working on a webgl project and, i don't know why, since this afternoon my build passed from 550 sec to 90 sec to be built with no error . BUT since the build crashes when put on the server with : Invoking error handler due to
RuntimeError: index out of bounds / Uncaught (in promise) RuntimeError: index out of bounds.
Does anyone has an idea or some direction to give?
which input system are you using?
Well, first of all I would check you Build scenes list, if all of them are there. As super reduced time in building could mean not all assets are being loaded. Aka you will get null reference when your base scene tries to load something.
Correct way to check would build in Developer mode and add full stack trace of logs, so you would see which script gives you index out of bound.
Clearing old build files and Choose BuildClean might also help. For quicker check you can try Build and run to check if it works locally without server (on this option unity creates temp server for u)
Tho most stupid variant is that you building PC not webgl, and trying to upload old build without checking 😄 that is super stupid idea, but hey time reduction is huge.
@astral wave THank you very much for yours advices !!
In fact i have only one scene in my build. I tried to rebuild several time ( i also restart everythings) but no sucess. I switched back to PC, then restart; and then switched back to webgl. The only thing that happened in the middle of this afternoon was that i losted intellisense in Visual studio and i got a message saying mostly " you don't have the visual studio tools in use and you need to change the external tool in unity...) It was very weird.
I will try a full stack trace and see what is logging.
Thank you. once i found the problem i will share my solution ( if i have one)
Well easy but not fast fix is:
Close unity. Delete your Library folder of the project. Open Unity project (it will rebuild library so it will take extra time).
Have in mind your default scene will be changed, so you will need to open correct scene again. And readd that scene to your build settings.
that normally fixes 90 % of problems
I was using the old one, switched to the new input system and it seems to be working fine :)
@astral wave Thanks ! It is one of my ideas to see what' going on, but in the past when i used it sometimes the project was totally destroyed ( lost reference to asset database....) So it' in the last resort for me.
Ok i 've found the problem. Some assignations was broken. ( Why? i don't know) And most of all, I did not receive any notification ( null reference exception.... ) Really weird. But it's working now. Thank you every one and thank you @astral wave 😉
gey guys, how do i get a skybox to not be distorted and glitching on my android phone?
i have been googling and messing with all sorts of settings for a few hours now, and cant get it to render properly
any idea what could be causing that weird distortion? ive tried several different skybox materials from the asset store and set them all to mobile/skybox and played with the settings
it only does it on mobile, when i play it on PC it doesnt do it ><
Hi, so I'm targeting WebGL for my game I'm making for my thesis in uni, I'd like it to be able to run in mobile browsers also especially on an ipad. I read somewhere on Unity's website that on v2022 they removed the warning for mob browsers on webGL build and also that they plan on supporting them in the future on their roadmap. My project is currently on v2021 stable and I'll probably hand it in in 2 months time. Do you think I'd get it running smoother (advantageous to switch to) if I tried v2022 or 2023?
I would strongly recomend 2022. It wont add too much smoothnesss or amazing improvments in performance. But there are bug fixes in that version, that are not in previous versions. If everything is working, stay with your version. If you want to add something new or are strungling with some bugs, update is the best choice.
I am sorry, I have no idea for the reason.
- I have seen similar effects on UIToolkit when device memory was reaching it maximum (have in mind browser memory on android is extremly limited)
- You can try different compression on your skymaps, as different devices likes different compressions more. Same with your project compression
Yeah it sucks. I hate working in webgl but it's what the client wants so 😦
we are all here because of that. except that one guy who thinks that webgl is amazing.
lol yeah. i just wish people wouldnt put so much emphasis on being able to play webgl games on mobile.
like, they work well enough on pc, but garbage on mobile ><
i wouldnt dare to say they work good enough on PC either.....
bruh I'm here cause professor wanta the game to play on iOS also but not pay for applestore and apple dev etc 😂
and he told me that after I accepted my thesis
ufffffffffffff
hey guys, whats the best solution for Voice Chat in WebGL but also compatible with Windows and Android (Oculus Quest)
Its for a metaverse project that will run on those 3 platforms
does this work with android too? can i make an app with this that goes for android and webgl simultaneously?
Hello, I have a problem with my webgl build, all the sound effect sound very off and weird. Is it something know about webgl ? I'm using unity 2022.1.18f1
i think the browser wont play audio until you make the initial click so the browser gives you audio capabilities, usually solved by clicking an HTML button like a play button and load your game then
I don't really understand what you mean, I have sound, it's just that the quality is really strange
my webgl build just doesn't sound like my windows/linux build
If you want voice chat on multiple platforms, forget webgl to have same solution. As other platforms can handle sound and directional sound and etc without problem, WebGL cannot do that. What you will need to do is Create JS voice communication and somehow connect it to your other platform voice servers.
you could try this plugin, it tested and works. but soon you will see the limitations of Webgl.
I found what was wrong but I have no idea how to fix this "properly". There is a issues with webgl build, when you play a sound, the first 0.1 second just don't play. It's why my sound were weird. A quick fix can be to just add 0.1 second of no sound before the actual sound but I think unity have to fix this issues them self.
I can't figure out how I actually run my webgl project. It just pops up with this wall of text.
Failed to download file Build/Builds.data.gz. Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.
I'm running it on firefox which is what the tutorial I'm following says works.
It did a while back when Firefox didn't default to that security policy. Just grab a web server program for testing or use Unity's "Build and Run" option to have Unity set a temporary web server for you.
It is important to note, that build and run will run only once. if you will close it you cannot just open the build in your browser again. you need to build and run again 🙂
Hey, I dont know if this is the right place to ask but I just made a game and uploaded it to itch.io, my problem is that i have a build in leaderboard with playerprefs. This works fine for pc builds locally but on itch it does not really make sense since everyone can only see their own scores. Is there a way to make the leaderboard shared and somehow save the data on itch.io or some workaround that could make it work?
thanks in advance (:
You need a separate service for that. Firebase is a popular choice.
if i build my game for webgl and upload it to itch.io it doesnt run it only works if i select development build in the buildsettings does someone know why that is ?
i get this error
I found a solution
You habe to disable buil compression in the player settings
Thank you very much anyways
On the other hand I'm not sure about Unity defaulting to suboptimal build settings because one of the most popular hosting sites has an suboptimal hosting configuration 😛
The visibility of this feedback will likely be quite similar if you make a thread on the forum and send a message through the roadmap page. Unity employee on the forum has assured that all roadmap messages are read.
The ideal solution would likely be for Itch.io to address this
Mobile isn't supported for WebGL I believe, you may need to touch the screen to enable sound for some browsers. But not sure how well or stable mobile works. If interaction doesn't do it, it is likely a unitybug with webgl for mobile
did you find a fix for this?
Unity is pushing to "officially" "support" mobile for webgl.
Sometimes I feel like Unity intentionally half asses things so that they can leave it up to individual developers to fix their mistakes and put it up on the asset store--in which Unity takes a whopping 30% cut of all sales.
What do you mean by this? It was officially unsupported, and Unity have been and are working towards officially supporting it.
I meant the same as what you said. It was not supported, but they're working to officially support it
To play sound and do multiple other actions, like go to full screen and etc, User interaction is required. I do believe it was changed with browser security things and cannot be workarounded.
What browsers considers interactions... well click is the easiest one. Devices usage is also total different story, like you are forced to use HTTPS to get access to most devices and etc.
I think you maybe replied to the wrong person 🙂
I think you are correct 😄 I just added to your answer 😄 an my brains did not work good enough to reply to correct person 😄 sorry
WebGL has been slow to adopt important back-end features, Unity's hands have been pretty tied with it
It's quite a bit of work to develop an engine that has to run and have feature parity in all scenarios regardless of device or browser
If I enable data caching and name files as hashes, does that mean I'll avoid issues with people having old data on new builds?
It avoids caching issues, yes. Make sure you keep your HTML template updated if you are using a custom one.
I am using a custom one. I don't understand what the html template issue could be - could you expand on that?
The names change in the template for each build
ah yes - that is part of my deployment process. Thank you!
hi there im having problem with WEBGL and addressables and caching, im since hours trying to fix it and all stuff i try so far dosnt seems to fix anything. in the player settings i disabled Data caching bool and still giving the error so its make me nuts.
the error its
Error while downloading Asset Bundle: CRC Mismatch. Provided 6b2caf2, calculated 477d6e31 from data. Will not load AssetBundle
i have try to parse the OperationException.message if contains the CRC mismatch for then call Caching.ClearCache();
but it results that you cant build webgl build with that line even if dont give error on visual studio, coz webgl now use other caching magic and there is no documentation on how to force to clear this cache...
any help please
what's the line of code to enable keyboard for input fields on android webgl?
https://docs.unity3d.com/Manual/webgl-input.html
I think you are looking for WebGLInput.captureAllKeyboardInput to true
Or WebGLInput.mobileKeyboardSupport
thank you.
Anyone here managed to load a glb file at runtime with the Khronos gltf plugin in a webgl build? We are getting no errors at all yet the model does not show up.
The official one? Have you checked out the Unity sponsored one https://github.com/atteneder/glTFast?
@sweet oriole No we are currently using the khronos one
I could try out a quick swap. Do you know if there is a ready to go API for loading a gltf model from a url at runtime ?
Looks like it and looks simple just add the component at runtime hahah
I believe it was originally specifically designed for runtime GLTF loading on WebGL.
yeah looks great. Looks like the team switched to this package last night and I did not know haha. Right now I'm doing a build with the shaders being put in the always include list cause we were getting some pink models loading in 🙂
it still doesn't work. The keyboard wont be brought up.
So, even if i bring up the keyboard manually, it still wont add the text to input fields. Any idea how to fix this, or is there a workaround?
Does Input field is focused correctly? You might lose focus when doing something. Which input system are you using? New one or old one? Confirm that your Touch settings same as mouse. I suggest to try input event debugger to confirm it.
https://youtu.be/vMLA5nx6vNc?t=999
Or you can just wait
Thanks for the help, but i fixed it. Tmp was in version 3.0.6, but i needed 3.2.0 pre release for input fields to work.
Hello peoples. When I publishj my game in webgl it lookes a little more zoomed in then it does when I test in unity. Any ideas to fix that?
Does anyone know of a guide/tutorial/code example/tool for exporting screenshots from a Unity WebGL game to Twitter?
There are tools on the store to handle this for iOS and Android, but nothing I could find for WebGL.
Your game probably has some scaling issues. You can test this out in the editor by undocking your game window, setting it to free aspect and resizing it around to see if you can replicate the issues.
Thanks so much!
From what I do understand you will need to use JavaScript. You can make screenshot file with Unity, then pass that data to Browser to its Javascript, and use Javascript to post that data to Twitter.
Yup! And you can also pass the screenshot out of unity pretty easily as Base64. Which should share to email/twitter easily enough. Twitter did lock down their api so it is much less interesting now to work with
Can I use on screen keyboard in a webgl build?
https://docs.unity3d.com/ScriptReference/Microphone-devices.html
I know that with microphones is pain in the ass.
So my guess is, becaus webgl dont have access to devices untill you interact with application, the initialization of default mic does not work for you. What you can do after first touch initialize devices list again and select the default version. This should work.
Tho I am pretty sure you using some kind of library right? as UNITY webgl does not really support microphone by itself. So there is something in Javascript side you can do.
if you use the newest beta input systems yes, they added it if I understand correctly.
But if you need IM you bit out of luck.
sorry my head was not in correct place. But the logic is the same. Make a button which check and debugs all Audio devices. Check if after pressing button it actually finds it. If it does then all you need to select the needed device after your fist interaction with WebGL
In my project it load audio devices on mobile corectly, but as my audio manager is created bit later maybe that is the reason.
the resolution is weird for my webgl builds
thats what it looks like in game
but then when i build it
it looks like this
The template is good to use since it kinda optimizes your Unity settings for smooth webgl builds
Also I use the Unity React component which you can set the resolution of the component in your html tag
er typescript
For one if you preview the game window at a specific aspect ratio, that will not guarantee it'll look the same on a different resolution, even if the aspect ratio matches
I think you should manually set it in Player Settings > Resolution and Presentation
Maybe try a static resolution too instead of an aspect ratio
Yeah
I did
So how can I guarantee it
Developing in free aspect allows you to catch some of these issues earlier, as it's something you probably want to properly handle over locked resolutions or aspect ratios.
You can adjust the camera to fit as much of the gameplay area as possible and make sure there is some padding content around it to properly support various aspect ratios.
yeah i usually develop in free aspect
what do you mean padding content?
sorry i havent touched unity in a minute
last time i used it was like 2 years ago
after your changes or before? 😄
I totally get you bro. I have similar problem with memory usage. My samsung 7 edge runs application, yet IPhone X and Xperia 10 gives memory errors 😄 Each device have it's own mind expecially on webgl 😄
The thing is non developers like webgl. They like it doesnt need to be on any AppStores. That makes it look more profitable and it makes it popular. Then developers are hired to use webgl. I really interested how they will make webgl multihreaded as they announced on Unite, then it will be biggest change for long long time. But webgl is not update by browsers for rly long time, so what ever you do you will be always behind.
Preview with the exact resolutions the game can be played at
Can I use photon in a webgl build? I'm going to use it to create a real-time multiplayer in my webgl game.
Varies between Photon products.
Heyy, i just finished a 3D game. Its size is around 600MB and i want to:
- make it downloadable on Windows and MacOS, as a desktop app
All the tutorials i found were on WebGL for itch.io, but when i switch platfrom for my project. Im getting 200+ errors, and i dont really need to run it in browser
Any other ways i can publish the game?
im sure i have a wrong understanding of WebGL. Can you run bigger sized 3D games on it? and can you download WebGL game as a desktop app?
Super random issue involving the fullscreen mode on itch.io:
The main menu UI does not scale correctly when I go into fullscreen mode. But if i play a level in fullscreen, pause, and go back to the menu, it is the correct scale. Until I go out of fullscreen, that is. Anyone know why this is happening and how I can fix it?
GetConfiguration then if it is incorrect AudioSettings.Reset. maybe?
As normaly it just streams audio to default system device, but obviously it doesnt it work 😄 I know Vivox audio plugin can select device. So it is possible, but most likely not exactly by native code. Frustrating isnt it?
or just go WebGL way, just use JS
navigator.webkitGetUserMedia(
{ audio: true, video: true },
function(MediaStream){
// success
navigator.mediaDevices.enumerateDevices()
.then(function(devices){
devices.forEach(function(device){
console.log(device);
});
});
},
function(){
// error
}
);
And select device you need.
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices
Hey y'all, have a web build of a Unity project that has always given us a huge error message when starting the game, it's never displayed or played correctly. Wondering if anyone who might be able to decipher it is willing to take a look
Framerate drops on WebGL when sound is played first time. I'm tried all different memory/compression settings, but doesn't change how it works. Is there some config I'm missing? If there isn't I'll just initialize everything by playing all sounds with zero/minimum volume on start.
Actually haven't tested profiler on this one, since it's browser only. Not big - largest ones are about 100kb as wav (so pretty much ~nothing as aac).
Could be combined effort of pooling system, particle effect and sound, but doesn't happen without the sounds. On chromium browsers it's so minor it sometimes goes unnoticeable. On firefox it's horrible.
has anyone ever embedded a webgl build into a kajabi website? Any tips, tricks or tutorials?
Hello. Is it possible to display on the screen the usage percentage of the browser gpu and cpu in a webgl build? Thank you.
is there anybody who can teach me how to implement wireframe green overlay effect on the hololens with three.js?
Greetings. It is less of compression format, but more about load type of the file. (https://docs.unity3d.com/Manual/class-AudioClip.html). I really really strongly recomend just build dev with auto connect profiler with deep profiling (allow your borwser to load non save content) and check exactly what causes it. Maybe decomprersing? maybe maybe file is not so good? maybe you start playing multiple of them? As from StarterAssets third person controller example that I tried running on webgl (running with footsteps), it did not cause noticable performance issues, you you might want to try that you and check how it is different.
Hello, I'm interested in using TMPro pre release with a Unity 2022.2 project to be able to use the pop-up keyboard in webGL, when on mobile browsers. Is the best version of TMPro for that 3.2.0-pre.3?
I'd give either photon realtime transport or websockets a try. Either one should let you use unity netcode over the web. The other option is doing something self rolled and using BestHTTP etc.
https://github.com/Unity-Technologies/multiplayer-community-contributions#transports
The good news, is if it is hard, there is less competition 🙂
You'll be fine. I've been using unity FT now for about 10 years, 300+ projects. Time goes fast. The first few are the hardest :). Eventually it gets easier. You'll know your doing well when you can code all week without pulling up any help docs
I keep getting this error when running my WebGL build in Docker NGinx
Config:
server {
listen 80;
server_name localhost;
location / {
root /webgl;
index index.html;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .+\.(data|symbols\.json|.js)\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip;
default_type application/octet-stream;
}
# On-disk gzip-precompressed JavaScript code files:
location ~ .+\.js\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip;
default_type application/javascript;
}
# On-disk gzip-precompressed WebAssembly files:
location ~ .+\.wasm\.gz$ {
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
add_header Content-Encoding gzip;
# Enable streaming WebAssembly compilation by specifying the correct MIME type for
# Wasm files.
default_type application/wasm;
}
}
Any help is really appreciated!
Did you restart the server after changing the configuration
Yes
So i get a 404 on a get call and these are the headers
I check in the docker container and it is present ...
Nope the loader.js is fine
Yes
Data.gz and framework.js.gz
unity-webgl-demo | 2022/11/21 16:33:16 [error] 32#32: *5 open() "/etc/nginx/html/Build/BuildopenGL.framework.js.gz" failed (2: No such file or directory), client: 172.20.0.1, server: localhost, request: "GET /Build/BuildopenGL.framework.js.gz HTTP/1.1", host: "localhost", referrer: "http://localhost/"
unity-webgl-demo | 2022/11/21 16:33:16 [error] 32#32: *5 open() "/webgl/404.html" failed (2: No such file or directory), client: 172.20.0.1, server: localhost, request: "GET /Build/BuildopenGL.framework.js.gz HTTP/1.1", host: "localhost", referrer: "http://localhost/"
Aha its looking in /etc/nginx/html and it is in /webgl !
So after making the root correct the next error!
in console: RangeError: Invalid array at BuildopenGL.loader.js:1:5827
Yes
Why is this so difficult :p
So the loading screen is stuck almost at the end whit this in the logs
I can try
But building whitout compression works only too slow ofc
https://help.kajabi.com/hc/en-us/articles/360040196893-How-to-Add-Custom-Code-to-Your-Page Contact their customer service to see if they'll allow you to embed something that works
Learn to add the Custom Code Block to your Kajabi Page.
In this article:
What is the custom code block used for?
Adding a custom code block
Customizing your custom code block
Page settings: Cus...
Thanks, it's for a client and I've never delt with Kajabi before, and not sure if it'll work. I was hoping someone already tried and could give me a definitive answer because who knows what their customer service is going to be like. But, seriously, thanks
Compression is disabled on the server
I usually see that when the server can't decompress the object, and returns an empty array. Resulting in a bad index
You can set it to compressed, with uncompressed as a fallback. While you troubleshoot the compression in the meantime.
hey, i'm trying to build my project on webgl, and i'm getting this error:
Error: IL2CPP error for type 'System.Net.WebHeaderCollection/RfcChar'
Hi, has anyone here run into these errors before? I'm getting this error when trying to send an API call through an HttpClient object
Does anyone know how to import npm modules for use in .jslib files?
I've been trying a couple ways but none of them work properly
I'm building more as an SDK rather than a game, so the goal is to try not to mess with the webGL template too much. Regardless if I have to that's fine. We have an NPM client sdk that we need to initialize from unity and then create a texture with a video frame to give back to unity later
Is that something I could do outside of a jslib file? I wouldn't have access to GL.textures there would I?
I figured as much. My solution right now is to eagerly load my library and add it to the window object which should be callable from the jslib
(that i found after I had asked the question originally)
Thanks for your help!
I am having trouble exporting for WebGL - I have a simple demo with some cubes and whatnot, and when I export for WebGL locally with the editor and play the game in a browser, it compiles and plays, but the scene is "empty" (no cubes or anything), but I can tell that it is starting "the right" scene because my camera controller is working (so I can look around at the skybox). I thought maybe things were strange because I using the Unity editor on Linux, so I tried building using the game-ci/unity-builder GitHub Action, and again the build completes and I can download the build and play it in a browser and it's also this strange empty scene. Any idea what might be going on, and what I can share to help troubleshoot?
many, yes, some are suggestive for sure:
The resource Internal-ErrorShader.shader could not be loaded from the resource file!
GL.End requires material.SetPass before!
hi I try to start a webgl project and want to implement a library. but i get this error on mac.
I want to download a nugget package
IotaWallet.Net.Domain
and the error above occurs.
I am on a mac.
I did not find any .net framework 4.7.1 for mac to download an install nor can I change to .net 4x in the player settings
or do I have ot make it on windows as .net 4.7.1 seems to be on windows only...?
FTR, I solved my issue by upgrading to a newer Unity Editor version, ha!
@grave cradle In case you haven't found about it, there seems to be some working solution (or maybe they became partial solutions now) about the .NET Framework 4.7.1 compatiblity with Mac here : https://github.com/OmniSharp/omnisharp-vscode/issues/3063
In short, some seems to have fixed the issue by installing Mono (or upgrading it) from https://www.mono-project.com/download/stable/
(You should read the link I posted above for various sub-cases where some people did a small additional change, based on cases.)
i see the problem is that in my unity project is no Dependencies/Frameworks and net core...
How can I add the .net 6 framework to a unity project?
or in an other way said: when I create a new project in VS directly i can choose the .net framework and it will be added to the project dependencies. But if I make a Unity project and enter the VS to check the project, I dont see any dependencies and can set anything...
I need the framework to install the nugget
while I get the .net frameworks automaticall when creating a project in VS I dont get it when I create the project in Unity
I did install it but it seems not to be the problem
the solution project form unity refers still to .net 4.71 framework... how can I add another framework and refer to it
or how can I implement the vs created project into unity?
so i am making a website using HTML and css, I would like to embed my webgl unity game into the website, ive looked on the internet but all the information is outdated
does anyone know what I need to do
thanks i looked into it apparently chrome doesn’t support unity webgl content
so i have to upload it to an external server
Modern browsers tend to have security related restrictions on running local content
yeah i figured that was the case. its not a big deal i’m making a portfolio and wanted ease of access
it won’t hurt my chances if i direct them to an external link
but it definitely could have upped my chances having it directly on the website
Well your website most likely is already hosted and not ran from local filesystem 😄
i havent hosted it yet
really?
let me send a screenshot
i dont understand what you mean by static website tool
im using html and js for this website
i am on windows
i most likely dont know any server side programming languages
what are some examples?
i think so
instead of just building the files
u want me to build and run, i think i read about this too. thats how i get the address right?
ohhh that is sooo unlucky then
the project i want to use i lost the source code to a faulty hard drive
but i was able to download the we gl files i uploaded to itch.io and thought that would be enough
unfortunately nope
This may have come up before but, I am having a really hard time downloading and playing audio in my WebGL builds using UnityWebRequestMultimedia.GetAudioClip - I have tried most things I am finding online (for example, setting streamAudio to true for the DownloadHandlerAudioClip), and have tried wav, ogg, mp3, and aac, all with no luck. myClip.length is always 0, and the audio does not play (though in the browser inspector, I do get a 200 response with the content-length header correct - and the body /looks/ ok, but I haven't tried to decode the gnarly ascii that the browser inspector shows). Any guidance here would be greatly appreciated!
Can you share code?
Networked content can be hard in webgl sometimes and have issues (like netcode for gameobjects not working in webgl right now)
This is how I am trying it now (works for non-web builds sort of, it doesn't seem to download the whole clip, despite the content-length header being correct):
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.MPEG))
{
DownloadHandlerAudioClip downloadHandler = new DownloadHandlerAudioClip(string.Empty, AudioType.MPEG);
downloadHandler.streamAudio = true;
www.downloadHandler = downloadHandler;
www.SendWebRequest();
while (www.downloadProgress < 1) {
Debug.Log(www.downloadProgress);
yield return new WaitForSeconds(.1f);
}
if (www.responseCode != 200 || www.result == UnityWebRequest.Result.ConnectionError) {
Debug.Log(www.error);
} else {
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
Debug.Log("Should be playing a clip of length: " + myClip.length.ToString());
AudioSource.PlayClipAtPoint(myClip, position);
}
}
This is how I used to do it (works for non-web builds):
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.MPEG))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(www.error);
}
else
{
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
AudioSource.PlayClipAtPoint(myClip, position);
}
}
I have been pointing the url at valid aac, mp3, wav, ogg, that I host. Neither of these seem to work at all for web-builds
Whelp, I got it to work, at a super low-level - I changed my server to send back raw pcm, and then I convert that into a float array that I can directly create an audio clip out of, and it works on webgl:
using (UnityWebRequest www = UnityWebRequest.Get(url))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(www.error);
}
else
{
var buffer = www.downloadHandler.data;
short[] samplesAsShorts = new short[buffer.Length / 2];
System.Buffer.BlockCopy(buffer, 0, samplesAsShorts, 0, buffer.Length);
float[] samples = new float[samplesAsShorts.Length];
for (int i = 0; i < samplesAsShorts.Length; i++) {
samples[i] = i16_to_f32(samplesAsShorts[i]);
}
int channels = 1;
int sampleRate = 16000;
AudioClip clip = AudioClip.Create("clip", samples.Length, channels, sampleRate, false);
clip.SetData(samples, 0);
AudioSource.PlayClipAtPoint(clip, position);
}
}
As long as I’m allowed to manually fill an audio clip with f32 pcm, I’m happy. But the two code examples above seem quite reasonable, but aren’t working. I’ve tried all of them with mp3, ogg, and aac. I’m using 2021.3.14 or something let me double check
yeah, 2021.3.14f1
Where can I host my webgl builds? I tried using github but my files were too big.
Hi guys, how do I fix this ?
I'm currently using nodejs https://www.npmjs.com/package/http-server
Anyone know if it's possible to store custom vertex attributes in gltf/glb? (or maybe there's other file format?)
Which files were too big? Your web build files shouldn't end up being too big to begin with.
Just tried using itch.io and the multiplayer and leaderboard in my game is working properly.
When i try to upload my game to itch.io it gets suck at 0% and i get these errors in the console. I uploaded my game before and none of these errors have shown up so i dont get what is wrong now
@ancient cradle is your WebGL compression set to none?
yes it is
Hey guys! I am having an error while trying to build for WebGL. The game builds fine for windows .exe. Can anyone help pls?
I am trying to build the game for a jam and dont have much time 😦
Hi. Is it possible to upload via FTP, in a WebGL build ? My script can run in editor, but not in the build. It is explained that this is happening due to threading that is not supported in WebGL. Is there another way ?
your code, or probably an assembly you're using, is referencing UnityEditor code and trying to compile for WebGL
Yes I found out which it was .. Thank you very much for the reply.
@strong wasp #📖┃code-of-conduct has a section on job/collab posting.
Are URP decals just totally unsupported? I found some people online who seemed to have them working (and had other problems with them). All I'm getting is as if texture was missing (opaque purple squares) and warning "Shader Shader Graphs/SimpleDecal is not supported: GPU does not support separate MRT blend modes"
tried playing around with different settings for decals and creating as barebones decal shader as possible, but no luck
well, turns out decals only work in forward mode on webgl
does anyone know how to ignore/disable WebGL JS Error?
(popup)
I have an curl error 28 error timeout
however this cannot be NOT logged into unity
so everytime there is a timeout, this appears
As in you can't catch it yourself?
I've surfed the internet, I dont found a way to catch the curl 28 error
Not aware of anything other than modifying the template to either disable the popup or try to check for that specific error
thanks
pretty much this error
i just use UnityWebRequest with timeout
Was just wondering what was timing out
it download some kind of 3MBs
ok I found it
try/catch works, however I do it inside Task<>
idk abt Coroutine
wait It didnt work
Careful with System.Threading on browsers
Is there a settings combo for URP decals which would work with angle fade? I’ve tried lots of different settings and can’t find any combination which would work
Hello, I'm got some trouble on chrome, sometime texture won't load like button
No problem on brave
chrome
brave
Someone knows what is the problem
hey, is it possible to receive the inputs from a laptop trackpad? Input.touchCount is not triggered by my laptops trackpad. i would like to implement pinch zoom and two finger drag for our trackpad users.
Does Input.GetButton not working? Should be the same input as the mouse click.
I'd start by looking at the debug console in chrome
my log on chrome
log on brave
I only see the shader error mentioned above, but it shows on both consoles, so not sure if it is an actual problem. Sorry I realize it doesn't help
no problem I will investigate more
Is it possible to call async function in jslib and get the result in C# ?
You can pass messages between the JavaScript front end and embedded unity WebGL
#if USE_THREADS
workerUrl: "Build/{{{ WORKER_FILENAME }}}",
#endif
soooo I find this in new template of Unity Webgl. Anyone can elaborate on this? And how to use this in first place, as I dont remember that Threads would be supported normaly yet (I know they said they will make it, but that is still future). So is this just for future references? or it is actually possible to use this somehow?
Yeah so I need to use send message, it's not possible to wait the response from the c# code, I don't want to attach my script to the gameobject
this is the error I got
non of the UI works for some reason but everything is to scaled and anchored correctly
Uploaded to Itch.io
Post the console error
How do I get the console error
Press F12 to open the browser console
I've messed with all the scaling and nothing changed it
Finillay I found a good solution with dyncall
Not possible to await a response? Can't you wait for a response in js using a static event callback that you subscribe to in the c# side?
anyone can explain where this is coming from?
- Quality settings have vsync off
- In editor there is no Vsync
- I even created this on Update function to make sure that target frame rate is always uncapped.
if ((Application.targetFrameRate != -1 ) && disableFrameLimitations) Application.targetFrameRate = -1;
Yet I still get this profiler data on webgl build. On different scenes it does get smaller but still exits. Any ideas?
sometimes you can see heavy drop down (which is actually means better performance.) Suprisingly then Physics querry get inreased usage. I am so confused.
How to find log of errors in browser
also , game is crashing on itch.io when game over condition is met
You can directly call a c# function from the jslib with dyncall method
So I didn’t need to use send messages or check every second if I have a response
press f12 to open console. If you want more detailed information change to develop mode and increase to fullstack trace and build settings.
Thankss
i am using agora voice webgl and geting error of agora any idea how to use in webgl agora.io
So im trying to upload my unity webgl project to itch.io, problem is the outer edge og the project gets cut off, even when i set the embem options to “click to launch in fullsceen”
Fellow devs, one question. I heard that some players seem to lose their progress they made in my unity webGl game.
I make sure not to save more than once every five seconds ( if there is a reason to save at all of course )
How are you handling that ? I am not using playerprefs, but saving a file goes into indexedDB anyways ?
Thanks in advance
So here is my question, I am trying to compile my rust code to web assembly and use this in my unity build. This all works, but we would like to multithread this. I am reading conflicting statements on multithreading in the browser, some state it is possible others say it is not.
Question 1: Is multithreading at all possible? If it is just within the compiled web assembly I am completely fine with that.
Question 2: Are there any guides or resources on how this is done? I have read some posts on it, but this seems expiremental at best.
Also, we are now trying to compile the web assembly with additional libraries, these libraries can be exported to web-assembly and without unity this does not cause any issues, however when we try to import the same .wasm + bindgen into unnity it doesn't work.
Question 3: Is there any documentation on how to setup the .jspre file when compiling Rust to web assembly for unity?
Question 4: Is it at all possible to compile with web assembly using additional libraries? And how is this done?
@sweet oriole (srry for pinging you directly, looking at other questions answered you seemed to know a lot about the topic)
https://web.dev/webassembly-threads/ covers everything I know and more when it comes to general use. I haven't worked with external wasm.
While Unity has been able to roll out threading on the native side as SharedArrayBuffers have matured, they have some additional challenges on the managed side with memory, threads and GC IIRC.
Hey I started to get this on unity 2022.2.1. Do anyone know where I can decrease this message size to fit into websocket?
// Start is called before the first frame update
[RuntimeInitializeOnLoadMethod]
static void InitProfiler() {
Profiler.maxUsedMemory = 200000000;
}
``` even if I force to use more memory it still uses more than it.
build.framework.js:2788 Stopping profiler. Profiler is not able to flush data to a file or socket and exceeded maximum allowed memory for buffering.
Please use Profiler.maxUsedMemory API or -profiler-maxusedmemory command line parameter to increase maximum allowed memory usage.
Using 200015872 bytes while Profiler.maxUsedMemory is 200000000 bytes.```
Another question, any idea why Video Player gives such horrible performance with default settings on webgl? I found some forums about it beeing like that for ages, maybe someone could elaborate?
Anyone know what is actually this Managed Heap and why is it so big, even bigger than the assets?
are you running this on editor?
Anyways, dont expect anything detailed in editor profiler. Build dev build and use autoconnect profiler then check.
Also for memory Unity have this:
https://docs.unity3d.com/Packages/com.unity.memoryprofiler@1.0/manual/index.html
Which will give you wayyyyyyy more detailed information.
Okay I will look into it thank you!
Hey guys I have another question regarding multithreading in WebAssembly using unity, we are using rust compiled to was to load the .wasm in Unity. I have read through the https://web.dev/webassembly-threads/ like @sweet oriole suggested, however no luck so far. Untill now we compiled without any aditional modules, which generates a completely different javascript bindgen.
I believe it is going wrong when trying the convert the javascript bindings into a .jspre file unity can read, here it is trying to import rayon functions as a module but I dont think Unity likes this very much.
Is there anyone who has tried this before, who can give me some pointers on the .jspre file?
@sweet oriole Do you know of any examples of multithreading WebAssembly using Rust and Unity? (with or without Rayon)
webgl pun2 multiplayer voice chat how to add
No. If you suspect Unity might be getting upset over some of these dependencies, maybe you need to add a bit more abstraction to make sure Unity can't get upset over it. Add your library to the site, add Unity build to the site and then figure out how to glue them together in JS. Obviously the interfaces need to be there, but they should be so plain that anything could hook into them.
Does ForwardRenderer+ URP works on webgl?
anyone using AWS Cognito with WebGL? If you have it working, I'd love to pick brains, as I'm getting a libc exception.
Not sure if people follow different channels since there are so many, but here's my problem that involves WebGL as well: #📦┃addressables message
Enable it and see. It's not hard to test
Thank you for your very helpfull comment. How in the world I couldn't think about it! (Mind blow). Have you ever tested anything on webgl? you know that is the best platform with fast alteration times, and nothing ever goes wrong there. Testing all features of rendering is super fast and easy way to do you are totally correct. It is way harder to ask community who might have already did that super easy task and are willing to share their experience so other wouldn't need to go over that super easy path of debuging. You are real hero!
Greetings. Could I make multiple things clear?:
- Does your game successfully loads at all? As this is very similar problem on start of the game, where server is not setuped correctly to handle compression you setup. Easiest workaround is on build settings to enable decompression FallBack.
with this you can confirm is it addressables problem or not. Because the loading addressables like you did in example should work,
Also you might want to add Await before both operations if you havent.
in three days of holidays and work I did not have time to test it. As now I am switching to real time rendering instead of baked one. So Profiling about performance differences and any visible bugs will take time between forward and forward+. Expected answer will be tommorow or today evening (without possibility of small shader problems which hard to find.)
I am hobbyist on Unity development and My day job is development on webgl 😄 One I like other I dislike 😄 Our project is multiplayer AWS webgl project, so if you wil have any questions feel free to ask 🙂
It appeared to be multiple issues on top of each other. I had to remove the Library folder before building, and also had to configure addressables to not compress and to not cache, and then also had to configure the nginx static host to instruct the browser to not cache anything. It's not ideal to not compress and to not cache anything but that's the only combination I got it to work without issues
welcome to webgl development 😄 thanks for updating for reason, will add that to my debuging lists 🙂
Got a question, Can I build a simple unity game in c# and then just export it as a webgl project so I can put it on my website? Not sure how the exporting works
Yes
Nice, sounds good to me so I don't have to learn 3js. Also what are the reasons that games on Unityplay website are really slow in fps?
I have a questions regarding the .jslib file.
I am importing a webassembly library and I can call functions from the wasm in the .jslib through the module created in the .jspre file:
Module["module_name"].function_name()
Now, how do I call a constructor from the .jslib defined in the .jspre through the module?
Normally I would just call 'new' on the type, but how does the syntax work when combined with the module?
Hi there, we have been working on a webgl project in our company. Client ask us to do it also facebook playable ads version of it. We've been trying to compress all the files because total size of build folder should be under 5 MB. I know that we should do the project in unity tiny but we dont have "know how" of it.
I have a 2 MB data.unityweb which is fine and we cant compress anymore files.
My problem is with the wasm.unityweb file. It's 4 MB and we need to reduce it to at max 3 MB.
Is there any suggestions on it?
We have been trying since last week. I'm asking here because we're at the end of our solutions that we know.
Unity Version: 2022.2.0b14
Hello guys, I am super new to Unity. I just finished learning Unity Essentials Path. I build a game few days ago and published it on Unity Play. But when I tried to play it, it is stuck on 90% while loading. Here is the screenshot. Is there anyone who has ever faced the same challenge. I would be super grateful if someone can help me solve this. Also, I am using Unity 2020.3.39f1
.
that's common problem on webgl, try to use another version
I prefer 2021 ... lts
Hey, iam trying to iframe web sites in webgl but it is opening in new tab Or not inside the scene
Is there any way to open it inside scene itself
there's some add on for such thing ...
it works but some button didn't work
like instagram follow button didn't work
Thank you! ....
Add on for webgl you telling right?
yeah it's web view for webgl as a recall, it's on marketplace
I don't think Unity default tool have that
I will try with the 2021 lts. Thank you so much.
Okay, thanks man
build.framework.js:2793 WARNING: 0:2: 'GL_EXT_shader_texture_lod' : extension is not supported
WARNING: 0:3: 'GL_EXT_shader_framebuffer_fetch' : extension is not supported
ERROR: 0:223: 'bitfieldExtract' : no matching overloaded function found
ERROR: 0:223: 'return' : function return is not matching type:```
Maybe someone know which option adds this shader texture LOD shaders?
Ichanged graphics settings for Everything baked to everything real time and start getting these lovely errors.
I'm hosting a webgl build behind a nginx reverse proxy. The proxy reports 504 timeout sometimes for assets that the client tries to download. The assets themselves are hosted in a docker container with nginx static file host server. I have enabled the following but the timeouts still do happen. I wonder if there is something else I can do? The container hosting the static files has 0.5cpu and 512MB ram available to it and it seem to be using less than 0.001 CPU and less than 8MB RAM while serving the files so I'm guessing there is something else bottlenecking the thing?
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
Not fixed in 2022, added in 2022.
The 2022.2 branch should work fine with it and has better WebGL features in general
@barren goblet #archived-works-in-progress for feedback and testing. Read the pinned post guidelines there and create a thread.
Nice!
Is it possible to have full canvas size with devicePixelRatio adjusted to it? Or alternatively can you scale the canvas and limit resolution some other way via JS/CSS/html? My project absolutely dies on full size browser and full resolution 4k or 5k. Smaller canvas and fullscreen WebGL works just fine, but I'd like to have that same fullscreen functionality without actually going fullscreen
Maybe you tested if it supports IME input as well? Aka for languages like japanese or chinese or others?
Does anyone else suffers from "linking build.js " takes forever on webgl builds?> Unity 2022.2.1
The thing I found was only
https://forum.unity.com/threads/webgl-build-linking-build-js-wasm-takes-forever.1315203/#post-8659683
Anyone else have more info about it?
lI found that disabling Decompression fallback reduces building time dramaticly. But still it is longer than before by huge mark.
Btw could anyone share their URP Lighting settings they use on WebGL? I am playing for ages now and want to compare my finding with other people
So what are your findings? I don't really see what there is to compare, since what is wanted varies between projects
🥺 i'm looking for some help with async/await in webgl, pls lmk if anyone has ideas! #archived-code-advanced message
It seems you found your solution. But yea switching to UniTask helps in webgl. Just be carefull use Unitask only then 😄 at least until threading will be available by native Unity
That WebGL is full of magic. That you need to have always minimum amount of settings on, otherwise it will be overflooded with shaders variants. Forward rendering + does not work and etc.
Tho my personal findings that Baked lighting is amazing for performance, but it add Memory usage. So for webgl mobiles, where memory max is 500mb you come to situation where using Baked lighting reduces amount of devices it actually can run at. So realtime you can run on shity FPS, but at least it works 😄 So I wonder what options people uses in their projects, what combination. Like Only a bit of baked lights and everything else realtime, or only real time, or only baked? As for my super simple project real time lights performance difference with baked is only 10%, which is smaller than I thought it will be.
I ended up not being able to fix it, I'm still stuck :(
remove this line from your code using System.Threading.Tasks; and try replacing all errors that you get with uniTasks
as Unitask have pretty much all features. Because webgl hates threading. That is the safest way I think
as webgl will not wait for any tasks....
yeah - i'm using a library that doesn't use UniTask, so there's one place I can't use UniTask 😭
and that's the part that's broken
Sorry to dissapoint you, you cant use that library then. Or you will need rewrite code on that library, because if that library uses Threading... it is GG.. sorry to hear that.
but as long code is open and you can change C# multithreading part it is possible.
or wait for a year or so 😄 they kinda mentioned they are working on multithreading. Tho no dates or real annoucments.
@astral wave Ok. I haven't delved deep into shader variant thing and don't really know what you mean here. Traditionally shader based forward rendering was done by having different shader for different number of lights, because branching was so expensive. I'm not really up-to-date with how modern forward rendering works regarding this, but sounds possible explanation.
Anway - here are my findings, not all are lighting related:
- Deferred doesn't really work. It does something, but number of lights was still limited, which didn't make much sense. It did do something though, since decals didn't work at all.
- Talking about decals - getting them to work was pain in the ass. I didn't find any documentation regarding what should work and it was just lots of trial and error. Didn't help that there seemed to be some bugs and sometimes editor functionality wouldn't update properly and you got impression that the settings worked and only way to find out what's really going on was to either restart editor or make a build.
- Performance of multiple pixel lights was horrible anyway, but I really wanted pixel lights, so I ended up limiting number to three - one for each player + one for casting shadows.
- And from there I faked the rest and went with decal-based fake lights, which are rendered into separate texture and use custom shader in post-processing. It's work-in-progress at the moment, but suits the needs of my current project. Need to figure out how to use one camera's depth buffer on another and if it even affects the decal system, until it's usable for anything else.
On topic of decals and URP, if you will update your unity to 2022.2.1 you will have pretty much no problems with decals. They added layers for them as well, but you need to add decals render option to your render options. I am using it now without problems (well some problem with rendering order when there are Spatial canvas around, but that is solvable)
well that sounds great
Decals shader is amazing idea, I wanted to implement that as well, but never find time to test if it actually performs better or not.
so, can you project decal to an object on layer 1, but render it on layer 2? :)
you can chose which light layer you project on. And then just set objects which layers they receive.
I guess I need to dive into light layers too
I am using decals to fake underwater effects. as u can see it is not visible on character but visible on other parts ( I enchanted the opacity to be able to see better.)
Doing fake light things on decal shader would be very limiting, expensive, hard or impossible, so I have very minimal decal shader and handle the fake light calculations in post processing. This is kind of deferred rendering-esque concept. I currently have very minimal game regarding collision data, so I just have duplicates of collision objects (without actual colliders) with black material, for receiving the fake lights. It kind of sucks, but works. It should be possible to make it work with anything though with screen space decals and using only depth buffer, but might require modifying the decal system.
I am. The depth buffer exists anyway, so I don't know what would be expensive here.
Like I think it would work like this: Grab depth buffer from main camera, use that on texture rendering decal camera, which renders nothing else and end result with screen space decals should be texture with only the decals projected on rendered geometry.
Submission, distribution
I've even seen "Submission Specialist" job title and tbh it really sounds more bdsm than gamedev :D
Hey guys I have an interesting question regarding async functions in my .jslib file.
My script component which executes the function does not seem to wait untill the function is executed...
My question:
- Is there a way to tell unity to wait for the async javascript function?
- If it is not waiting how does it handle return values?
Who knows what happened?Is it not supported by webgl or is it set up incorrectly,Help me
WebGL URP Decal Layers Ineffective
Hello, happy new !
I have a weird issue when building on WebGL, the sensibility of my mouse is like x1000 compared to the editor.
I didn't found anything online (except that sometimes the sensibility is x2).
Does anyone knows how to fix this ?
After a few test, I noticed that my sensitivity on the WebGL build is really x1000 compared to my Unity editor
Never scale mouse input by Time.deltaTime
Thanks for your reply !
It is currently using Time.fixedDeltaTime, so this one is okay ?
better, but still wrong
What would be the solution, just not using it ?
Don't scale input by deltatime
Btw I am not using it on all move/rotate so it is not only linked to that
Also why was it fixedDeltaTime? If it's in FixedUpdate that's also wrong
Well, I am working on a project made by another dev and I was kind of surprise to see that so thank you too point that out, I'll remove it and test
He was also using "LateUpdate" for some reason, should I use "Update" ?
tryign to upload to ld and getting this error can someone help
Uh oh!
If you're seeing this error, it means I can't find your index.html file.
This usually means you created your .zip file by zipping the entire folder, and index.html is somewhere like MyGame/index.html. If you recreate your .zip with index.html file in the root, this error should go away.
See the embedding guide for more details. ludumdare.com/resources/guides/embedding/
404 Not Found
its 4am i need help
Hey, I have a message thats supposed to fade in after my boss fight, and it works in the editor player... but it doesnt work in the webGL build
any idea why?
I'm using TMPPro and the script is pretty simple
just using an event to activate a game object, and once the GO is activated, it does
if (TMPR)
{
if (TMPR.color.a < 1)
TMPR.color += new Color(0, 0, 0, 0.5f * Time.deltaTime);
else
{
if (nextObject && !triggerNextByEvent)
nextObject.SetActive(true);
}
}```
heres the full script
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
like, is it just failing to get the TextMeshPro component in the webGL build??
if so, how can I fix this?
Hello dear Ori,
Adding the error log would help a lot. You can do that on browser pressing f12 you will see console with logs. For exact error code you will need to enable devbuild and in publish player settings full stacktrace. This will show the error.
Most likely what happens on webgl is that order of initialization is different.
a) SpellCasting.e_OnSpellCast += CheckForHealCast; event is not registered correctly. Aka it tries to be registered before spellcasting is actually initiated.
b) some of you if statments do not return correct value. To make sure you will need to add debug log in places and check how it changes values manually. Sadly webgl is not friendly with debuging.
Anyways my guess this script tries to access something that still does not exists. Simple workaround when you access different scripts check if they are there, and if not reassign it again.
I think the order of init is the issue
I remember having a similar issue in the past, over a year ago, and the order of start vs awake I think was the issue back then
I'll try a couple things first, but if they fail I'll do a dev build and see what happens
Also, the OnEnable is irrelevant to the issue I'm having at the moment, thats a part of the script that only is used in special circumstances, and not being used here where I am having this issue
alsoalso, I dont think a. is an issue, as SpellCasting is a script that is loaded in a separate scene with other core game scripts, before the level is loaded. it will always be intialized before anything in the level is even awake
as for the if statements, the script has been working fine up until now. I was udner the impression doing an if statement on a component returns false if the value == default, and true if it is anything else
fixed it
so it seems what was going on was OnDisable was happening in the webGL build, unsusbscribing the script from the event, despite the object supposedly starting as inactivate
in the editor mode, the scene was already loaded so it wasn't an issue, but in in webGL it was
I guess when a new scene is loaded, all object are loaded as active, and then set inactive after awake
So, I'm upgrading a webgl project from Unity 2020.3.38f1 to Unity 2022.2.1f1...
I'm getting the following error in 2022.2.1f1 (works fine in 2020.3.38f1) - this is at load time and everything just freezes (progress bar stops ~90%). I don't see anything different in the template html (e.g. createUnityInstance params look identical).
I don't see any 404s or other errors in the network tab of developer tools. Executing in incognito tab so nothing is cached. Chrome Version 108.0.5359.125 (Official Build) (64-bit) on Windows.
I can sort of manually trace through the minified build.framework.js calls and see them there but have no clue what they're doing or what is trying use document.querySelector with # - from the call stack I'm guessing it's trying to bind keydown events, maybe related to the input system? Maybe the canvas?
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#' is not a valid selector. at findEventTarget (http://localhost:8000/build/Build/build.framework.js:10:236557) at registerKeyEventCallback (http://localhost:8000/build/Build/build.framework.js:10:263148) at _emscripten_set_keydown_callback_on_thread (http://localhost:8000/build/Build/build.framework.js:10:263463) at http://localhost:8000/build/Build/build.wasm:wasm-function[111901]:0x1dbcdb6 at http://localhost:8000/build/Build/build.wasm:wasm-function[111898]:0x1dbc3ac at Module._main (http://localhost:8000/build/Build/build.framework.js:10:365581) at callMain (http://localhost:8000/build/Build/build.framework.js:10:479511) at doRun (http://localhost:8000/build/Build/build.framework.js:10:479958) at run (http://localhost:8000/build/Build/build.framework.js:10:480130) at runCaller (http://localhost:8000/build/Build/build.framework.js:10:479170) at Object.removeRunDependency (http://localhost:8000/build/Build/build.framework.js:10:15586) at http://localhost:8000/build/Build/build.framework.js:10:1913 at doCallback (http://localhost:8000/build/Build/build.framework.js:10:146856) at done (http://localhost:8000/build/Build/build.framework.js:10:147010) at Object.reconcile (http://localhost:8000/build/Build/build.framework.js:10:140291) at http://localhost:8000/build/Build/build.framework.js:10:136396 at index.openKeyCursor.onsuccess (http://localhost:8000/build/Build/build.framework.js:10:138147)
I haven't seen anything online or in the forums so I thought I'd try here.
Any ideas? Known issue? Might be able to give more info or answer questions, if helpful.
If you're using the Resources folder it can significantly add time to that
are you using old index template file? maybe there were changes in templates.
it takes 25mins per build for me
also 2022.2.1 have increased build time sadly.
By how much?
If you already cleared your library (so you can make a new cold build and then warm build) and it takes longer than previous versions make a bug report
(@orchid bridge)
For the same project build times should reduce or stay the same
there is already bug report about it. At least in unity forums that was stated.
Ah alright, cool
Our build increased by around 10-15 minutes if warm.... If not...... God help me 😄
Oof, thats not great indeed
Which version were you on and did you already delete the library folder?
problem was emscripten version update. Some users were able to reduce building times by replacing 2022.2.1 with 2022.1.23 or 2022.1.21 version emscripten files.
yes indeed I deleted library after unity update, as it was not building at the start at all 😄
Currently I am on 2022.2.1f1
For posterity on this one, you MUST have a css id on your canvas element in newer versions of Unity. 💥
Yup. Inside a SPA.
Of course!
Vue
Choice was made by someone many moons ago, who is no longer around. Guess would be it's an "better developer experience" or something. It's not a terrible choice... we're doing a bunch of other stuff besides Unity so makes sense. Also a source of many issues which get blamed on the Unity side. 😦
With regards to Unity, you have to be careful with memory usage from the SPA which is shared. Caching of unity instances is another one.
I'm on 2022.2, I have my game exported for WebGL. All sounds play perfectly on PC browsers and android. On iOS I get no sound. Any idea what the problem could be?
welcome to iOS. Most likely is because of security policies on iOS browsers. Trick is, no video or audio can be played without user request. Aka you need to click at least once first before you can try starting audio stuff. And Unity webgl clicks does not count 😄 There are multiple tricks for that, creating invisible HTML button to press, or create HTML pop up before game. I find out that you can use unity event: OnPointerDown() to trigger media unlock for iOS. I have button in my game which says; Tap to unmute. But what this button actually does, it is event onpointerdown (not on button click!!!) and it start audio.
hi, im getting this error when trying to upload to itch.io. i followed multible tutorials but they all result in this error. i have no idea how to fix this.
Anybody that can help?
Disable compression on Build settings. Or setup server to use compression. as now you are using brotli compression.
PlayerSettings -> Publish settings -> Compress -> NONE
ill try that now
this worked btw thanks a lot!
Glad to hear, good luck with webgl suffering ❤️
it actually works with no bugs, well not bugs that wernt there in the windows build, if ya want you can try it. its quite hard but ye https://jonesy-b.itch.io/test
it is really a BossGame. But froxe on start button :DDDDDDD no bugs 😄
ohhhh or it is all there is to it?
ohhhhhh there is no mouse support, got it
my bad
I have found a game on itch.io I would like to embed in my own project. It is open source.
itch.io: https://primozov.itch.io/zombie-retro
game source: https://github.com/lucaslprimo/ViceZombieCity
I would like to be able to click on an item in my scene and have the game pop up and play without leaving my parent environment.
Is this possible?
If this game is open source and on Unity why not just make different scene for this game. And load it as different scene or in additive way. Make it into addresables package and you will be able to load and unload game as you please.
Otherwise your only option to open it in another window or create aditional canvas with loading different webaddresses.
Great! This is what I needed to know. Yes, it is open source, so this can be done.
can you describe what you mean by an "additive" way? The way I envision it is to have the original scene visible in the background but greyed out, and the game in the foreground, taking up 80% of the screen.
In unity you can load new scenes in two modes: Single or Additive. Additive means everything that is in current scene will stay there. In this way you will have two games running at the same time. For further control you can use cameras stacking to control what and how will be seen. But have in mind multiple cameras or multiple games at the same time will consume way more resources, and webgl is not shining with performance already. So you might want to create some of fake workaround, like making screenshot of background, render it as bakcground and meanwhile disable everything or even unload your main game assets. But for starters the easiest implementation is addressables + Additive scenes + camera stacking. Both have quite a lot of example and tutorials, so I suggest investigate it
Or you can even make something like this; aka rendering of another camera which your another scene runs different game code:
https://www.youtube.com/watch?v=uSqYCGzlHZY&ab_channel=aboutgamemaking
but I would suggest having as minimum cameras as possible in your game, as rendering is the most expensive thing most likely,
Excellent advice, thanks so much for explaining
lol WHAT? why is that a thing lol. Anyways, so if I add a click to unmute button in my unity scene that triggers the OnPointerDown() it should work. I'll give it a try thanks
i tried to build my game to WebGL to put on itch.io but when i run it from itch.io it says Unable to parse Build/WebGL.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug.
Switch compression from Brotli to Gzip in WebGL player settings.
https://issuetracker.unity3d.com/issues/webgl-build-times-have-regressed
Will be fixed in 2022.2.3 (or maybe .4?) @clever lion
Many informal observations of the WebGL build time, in particular the final linker step now take longer than when we first moved to ...
Yeah it sucks right now.
You can roll back to 2022.1.24 or continue developing and wait for the fix to be released in the next few weeks (maybe test on Desktop builds instead for now?)
Is it next few weeks though?
22.2.2 just got released
I think they aim for a release every 2 weeks
So test without webgl if possible untill then and only make release builds with webgl?
We've never had a 2022 build pass our own internal QA. I wouldn't use it for production at this time, so no, we haven't / wouldn't use it right now.
The last version we tested failed on our Android, VR, and WebGL test scripts. We haven't tested it in a while now though
well, I rely on entities so... 😅
https://tnt-mania-1.itch.io/untitled-golf-game what should I change about my web page on itch.io to make it better or more appealing
Pictures and gifs @past vale
ok thanks
wait you able to use entities on webgl build? O.o
Yes. Just no jobs
Or subscenes
does it gives you enough improvements without Jobs and multithreading?
or it is more testing purposes with hope Dots will come to webgl in the future? 😄
I use it primarily for project architecture and burst
I thought burst dont really work with webgl, tho to be honest my project dont really have anything that burst compiler could help I think. But I didnt know it can be succesfully used with webgl as of all webgl limitations.
Why wouldn't it be?
have you done testings how much performance increase it gives you?
Well burst compiler does miracles with jobs, and all examples were provided with jobs pretty much. So I assumed it does not go well or is worth
But burst compiler requires you tu run simple mathematics. On basic projects what does it give? Like physics is not on burst, raycasts also not so much, if you dont do mathematics every frame how does it improve performance. I have burst "enabled" , but never added any tags to use it 😄
You convert your heavy logic to it
Everytime you have big loops
Yoy can try burst them
And get x4 perfomance
With vectorization
Maybe my project is just too simple, I cant find where to use it 😭 as 90% is just rendering graphics
but thank you for proving me wrong, that entities and burst is reasonable to use on webgl, I will double check if I can increase performance anywhere with that. What mainly you use it for? Like character controller? interactions between objects?>
Nah, nothing like that
It's pure math for me
It's economy management quest
But
I used to make a semi flappy bird game with entities too
I gave up for now, cause 1.0 entities graphics is too unstable (also propably incompatible with webgl atm)
It's mostky ecs atchitcture that I am after
We are using Mirror library with Insight (mirror master server for scaling) for multiplayer. It runs on AWS servers. I can highly recomend mirror, as community is really good and they constantly improving it. But for faster development Unity netcode is really good as well, as you can use their matchmaking and gateways for free while your project is small. Depends on how much power you need. If you will need crypto stuff I think it would be easier to go with your own server or AWS or others. where you have more control.
Hello, I have a problem. I just finished my game and had it built for windows and webgl. The Windows version of the game runs perfect as expected, but in webgl, some unexpected behaviour is happening when the game is running. The webgl version is executed properly, I have gone to its home screen, and other stuffs, howoever there is this bug which affects the gameplay massively. What settings can you recommend for me to be able to build the webgl version properly? I've tried running my game on itch and simmer, but both of them had the same results. I don't think the problem is with my code since it's working perfectly on game mode and the windows version of the game, so the problem might be with the build. What webgl settings can you recommend when building it?
Yes that is correct. We manage project ourself, as it integrates other weeb interfaces a lot, so it is easier this way.
So from your explanation I assume that game actually starts. My guess you havent checked limitations of WebGL and using one of the following: threading, tasks, VFX, jobs. Which neither of them works correctly.
cannot import assets when editor is importing or compiling assets its doing neither
Have you tried restarting Editor? have you tried restarting pc?
For me sometimes it stuck on switching platforms until I kill process and reopen it. but it depends on situation 😄
closing your code editor sometimes helps as well
still erroring
Close your editor. Close everything. go to your project. Delete everything that is in your Library folder. Open project again. Have in mind it will take longer than usual to start, as it recompile stuff.
iOS audio source question. Please have in mind that everything works on Android, Windows,
- I have script which downloads song
var dh = new DownloadHandlerAudioClip(url, AudioType.MPEG);
dh.compressed = true;
dh.streamAudio = false;
<..bla bla bla waiting for donwloading.. >
return dh.audioClip;
- then when it finishes apply on audio source and Plays()
- Super simple. BUT on iOS does not play any sound. Neither when click on button to play. Logs says that audio source is not null and it starts. No errors, no warnings.
- if audio clip is in the build, and not downloaded, it does play when I press play.
Any ideas? Only clue maybe because compressed = true? but have no idea at all why. Because as I mentioned, on android there is no problems, windows no problems.
Behavior same on safari and chrome.
mp3 or wav, same thing....
Use debug logs to see if there are errors, what the audioclip is, etc
Logs says that audio source is not null and it starts. No errors, no warnings. No errors. As it is downloaded audio clip, it does not have name, but it is returns that it is not null just like on all other platforms.
public IEnumerator DownloadAudio4(string downloadLink)
{
Status.text = "Download started";
var dh = new DownloadHandlerAudioClip(downloadLink, AudioType.WAV);
//dh.compressed = true;
//dh.streamAudio = false;
using UnityWebRequest request = new UnityWebRequest(downloadLink, "GET", dh, null);
request.SetRequestHeader("Access-Control-Allow-Origin", "*");
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(request.error);
Status.text = "Download error";
}
else
{
//AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
BGMSource.clip = dh.audioClip;
Status.text = "Download completed";
Debug.Log("Download completed");
}
}
Anyone know why this dont work on iOS only? I reduced the cause is when file is downloaded something goes wrong and it does not play. Wav and mp3 have same behavior. All completes succesfully without problems. yet no Sound. If file is included in build, that sound plays. SOmething with iphones and their decoding or something?
And yes there is a button that starts play() 😄
public IEnumerator DownloadAudio4(string downloadLink)
{
{
using (var uwr = UnityWebRequestMultimedia.GetAudioClip(downloadLink, AudioType.WAV))
{
((DownloadHandlerAudioClip)uwr.downloadHandler).streamAudio = true;
yield return uwr.SendWebRequest();
if (uwr.result == UnityWebRequest.Result.ConnectionError)
{
Debug.LogError(uwr.error);
Status.text = "Download ERROR";
yield break;
}
DownloadHandlerAudioClip dlHandler = (DownloadHandlerAudioClip)uwr.downloadHandler;
if (dlHandler.isDone)
{
AudioClip audioClip = dlHandler.audioClip;
if (audioClip != null)
{
BGMSource.clip = audioClip;
Status.text = "Download completed";
Debug.Log("Download completed");
}
else
{
Status.text = "Couldn't find a valid AudioClip :(";
}
}
else
{
Status.text = "The download process is not completely finished.";
}
}
}
}
This does not work either. Is it because iOS don't support something?
Created 7 different methods of downloading wav or mp3. Nothing Helps... even ChatGPT is out of options
Is there a way to have some editor code that will add additional html code into index.html of build?
Not that I am aware. Well static way -> you can just edit your template. But otherwise most likely you will need to write javascript plugin for your self. it is not hard tho.
I guess I phrased wrong. I'm looking for a way to make proper settings for different sdk implementations
I have 2 sdks, for 2 different platforms
sdk manual suggest adding js scripts manually in index.html
is template what I'm looking for?
Yes, template is what you looking for. Well you can always edit manually after build, but template lets you do that automaticly on every build.
Or you can add to template to read some specific javascript,which you can change whenever without needing to rebuild.
Is there some kind of pattern for embedding different SDKs into game per platform?
I have WebGL app I want to release on 2 different platforms with 2 different SDKs.
And I'm trying to figure how to properly develop it, to avoid writing same code twice. But sadly, in order to embed SDK I'd need to modify WebGL template, which is really app specific.
I'm considering creating a common wrapper that will send/receive events depending on enabled sdk
Anyone familiar with JS?
If I do this in <head> of html page
<script>
var myVar;
//Some Init method that initializes myVar
</script>
Can I then access myVar in other scopes?
I'm trying to tie sdk with Unity scripts
I'm upgrading a webgl project from Unity 2020.3.38f1 to Unity 2022.2.1f1...
Has anyone had issues with shaders (pulled from asset bundles, which we can't update) that worked in older versions of Unity but stopped working when upgrading unity versions?
I've posted some details here:
#archived-shaders message
#💥┃post-processing message
java script read from top to down. Anything that is above will be accessible for other functions as long it is not in function.
well for the shiny materials make sure HDR is enable in your renderer options. also make sure that your render options have correct transparency and depth options. As some shader requires depth or transparency to look in specific way, and if renderpipeline options will be disabled it will look that way. also make sure it looks that way only in editor or in build as well.
Can I use structs in Webgl?
My current code is bugging becouse of a system i made with struct, every time I try to access the matrix of Structs the build stops working but the desktop test works properly
Considering that things like vectors are structs, it would be pretty hard to do anything if they weren't supported
hmmmmmmm, soooo... yeah I dunno what is happening, will try some extra tests before comming here again
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Ok, I can't find what is causing the following bug
Maybe you are running into a memory limit of webgl? Looks like matrizCabeloXRoupa is causing you some issues, just a blind guess tho
2022.2.2f1 is out but no improvements on webgl build times..
You sure its the Unity part being the bottleneck?
I think the problem might be with the Matrixs, it seems that it bugs every time I try to access a [][] variable
either to get what is inside or to get the length
Yeah, I mean you got a three dimension array there, that might hit some memory caps depending on the objects held
damn, there I go again having to use structs to get around a unity lack of adaptability
It's pretty important to note that Unity WebGL handles memory very differently. Garbage collection isn't immediate, so looping and iterating can overrun the memory quite rapidly depending on the datasets.
So a multidimensional array could very easily use it up.
You can also try overriding the memory limits and using different browsers as the limits are handled differently per browser, to try and see if that is the root cause.
But I've also seen Unity cause some interesting errors in WebGL with loosely defined fields. But I'm not seeing that issue in your code.
Hi, I have a simple question about Unity WebGL builds. Would it be possible to run an online multiplayer unity game that runs on the browser ?
Yes
2022.2.3 is out and should improve build times!
Happens when running the WebGL build made with Unity 2020.3.15f, can anyone point me in the right direction?
Hi!
I'm trying to use these lines in webgl but they have no effect. The chrome console does not report any warnings. In editor they work fine. Any suggestion? Thank you
Graphics.Blit(renderTexture, textureSupport, mMaterial);
Graphics.Blit(textureSupport, renderTexture, mMaterial);
https://forum.unity.com/threads/blit-to-from-rendertexture-texture2darray-slice-not-working-in-webgl-built-in-and-urp.1311077/#post-8294612 might this one help?
Thank you. I found this link, but I didn't quite understand the workaround they propose. Or it didn't work for me.
Hi everyone, does anyone know how to turn on CORS on the Unity gaming services bucket to build to webGL? I've tried looking for the menu for CORS in the bucket but haven't found one.
thank you.
Do you get any error or how do you determine cors to not be working?
wait a second, i'll send you SS
Access to fetch at 'blablabla' from origin 'http://localhost:63908/' 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.
@torn pagoda i got that from the inspect console
Well, it tells you already what is missing. No Access Control Allow Origin present on the resource. So whatever server you are trying to access, I guess local, you need to add a access I think XML file
However you fetch your data, you need to do it with a correct header,n ot xml, that was crossdomain policy, my bad 😄
That might help
i'm using Unity Gaming Services, not local.
i adding this too
www.SetRequestHeader("Access-Control-Allow-Origin", "*");
and nothing changes 😢
Okay let me check, thank you
Oh, I guess your issue is, that you are trying to get a web service response to your local service. Unity Gaming Services might not allow that. what are you trying to fetch, can you show the code thats calling it?
Urghs, please use codetags 😄
!cs
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Okay, sorry...
i'm new here
Thats why we have those commands 🙂 so you know now 🙂
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Like this? @torn pagoda
i try to get background image on bucket Unity Gaming Services
According to this it sets the CORS headers automatically if the request is correct, if this is the same service: https://forum.unity.com/threads/unity-ccd-management-api-cors-policy-issue.1259918/#post-8008385
Note that setting the header in the request does nothing, it has to be set on the server
Does the request work in the editor?
Thanks for answering, I've been reading this forum, and that's why I wanted to ask if anyone can tell me how to enable CORS via the Unity Gaming Services dashboard. Because I haven't managed to find it.. maybe there is a special tab or button for that.
Yes, i'ts working perfectly
It's saying that it enables CORS automatically
Open the network tab in the browser's console and check that the request it sends is correct and it gets the correct response
Okay, I'll try it first.
thank you.
@arctic rose here it is, get error code 301
wait, I want to do something
still get the same error, do you have any previous experience with this? @arctic rose
Does it open the file if you right click it in the network tab and choose "open in new tab"?
Yes, it's open like this.. and then i get the "content_link" key for the URL video,
Ok. Then I don't know, sorry
Okay, thanks a lot!
when i try to build my project with webgl, the build with this loading bar always takes up to over 5 minutes. does anybody know how i can shorten that time
Only 5 minutes? That's very fast
so its normal that it takes that long?
No, usually it takes much longer
It depends on what you got in your project. Like materials, meshes, shader (variants) and what not. And of course on your machine. I can build bigger ios projects in 2 min but had small unclean projects that were taking longer. WebGL needs to have a lot of stuff being converted to work in the browser, so that might take some time
And as said, 5 min is quite fine depending on the resources
okay thank you
My build was 1 hour long last time
😅
My average for WebGL is about 10-15 minutes
1-2 minutes for Windows build, conversely
I went from 25mins builds in 2022.2.2f1 to 45mins builds in 2022.2.3f1 😔.. no changes to the game
We have projects in the 40GB range that can take over an hour. It just depends on how big everything is
Sorry, yes and no. We have games that have a 40GB repository but those are desktop/VR. The biggest web project we've done is about 100GB total. Specifics in this as a thread if you are curious 🙂
You need to disable compression
okay thanks
this?
Yup! I'd set it to compression anything then check Decompression Fallback though for the best of both worlds
It works
Next stop: world domination 🙂
I have a webGL build using URP that renders normally in the editor but when its built the camera doesn't render anything but the UI. the game sounds like it is running normally in the background and the console isnt showing any errors (its not showing the console at all actually but iirc the console doesn't come up in a dev build unless there is an error). Sorry if this is a bit basic ive been out of unity for a bit and I cant seem to find anything with google
I got a question, when i publish my game, the canvas works, when i then run the game on a different monitor the canvas either gets to small or to big, how can i fix this?
Testing, prepping and building your UI for different resolutions
For example, adding a canvas scaler set to screen resize at 0.5f, with the base resolution your ideal test resolution
Hey, theres an issue with my shader where it makes the actual game just black. The UI is there though, just the stuff the shader affects. I think its not a shader issue and a webGL issue because it works fine in windows builds. When I take the shader out the webgl build it works fine, this issue was fixed for my windows build by adding it here. Is there a similar option for web build settings?
I thought this setting would work for both but I guess not
so anyone have any idea why my WebGL build is not working when i upload it to Itch.io? the game starts to load then freezes near the end and there's a "Uncaught SyntaxError: illegal character U+FFFD" in the console
oh wait im an idiot i thought i had changed the compression from Brotli to Gzip in player settings bc itch.io doesnt support brotli but i guess it hadnt saved. no problems at all now
How is the shader made?
URP or built in?
Which unity version?
Hey guys, if you are planning to have a WebGL build in addition to the mobile build, would you create a new project for the WebGL version, or create a different branch in the same version control, or just have #if #else cases to handle different SDK initializations??
Thank you, I was leaning towards that line of thinking.
Don't toggle on "Development Build" it will build much faster. Also usually it takes long time only to build the first time, subsequently it takes much less.
I have a few questions:
How do I fix bugs that only happen in the WebGL build?
Are there any common crashes that are WebGL specific?
Is there a way to access the actual error logs?
Also what does this code do:
FS.syncfs(false, function (err) {
if (err) {
console.log("Error: syncfs failed!");
}
});```
Found in https://docs.unity3d.com/Manual/webgl-debugging.html
"Call the following code to make sure Unity flushes all pending file system write operations to the IndexedDB file system from memory"
Is this something to make sure data is deleted, saved or loaded?
And what is FS?
Also I've noticed I'm getting this error in the javascript log
Is it related?
warning: 2 FS.syncfs operations in flight at once, probably just doing extra work
The crash/freeze is something that happens about once every 20-40 minutes when changing scenes. No idea what causes it
Can anyone understand this?
The .jslib code:
mergeInto(LibraryManager.library, {
function syncDB() {
FS.syncfs(false, function (err) {
});
}
});```
The C# code:
[DllImport("__Internal")]
private static extern void syncDB();
void SaveWebGL()
{
#if !UNITY_WEBGL || UNITY_EDITOR
return;
#endif
syncDB();
}```
I changed the syntax slightly and that seemed to fix it
mergeInto(LibraryManager.library, {
syncDB: function () {
FS.syncfs(false, function (err) {
});
}
});```
I'm having an issues with webgl + windows 10 display scaling. When scaling is greater than 100% (native resolution), the coordinates in my game get all messed up.
Oddly, this doesn't happen at all in the "play" mode in the editor itself.
Very easily reproducible but I'm not even sure where to start looking for whatever would be sensitive to display scaling - just poking around player settings now.
Any thoughts?
Hmm... fiddling with devicePixelRatio in the generated html seems to "fix" the issue.
Ah, okay - based on these two docs:
https://answers.unity.com/questions/1252357/unity-editors-interface-scaling-on-windows-10.html
https://docs.unity3d.com/Manual/webgl-templates.html
Looks like I need a webgl template to force the setting.
just o be clear, WebGL doesnt rally have anything in common with operating system, it is more about the browser. But what you find is one of approaches, but the key element is understanding that Untiy editor is just half of webgl, you will need to edit WebGL template, css maybe even javascript in order to make sure the canvas will be scaling correctly on every device and browser.
You can solve the problem you have with correctly setting up css of canvas object.
Hey I am having a problem of some shader-fu I'm doing not working in webGL
Sprite MaterialToSprite(AfterImageParams e)
{
RenderTexture _renderTex = new RenderTexture(e.playerAIRT.width, e.playerAIRT.height, 24);
_renderTex.filterMode = FilterMode.Point;
Material _shaderOutput = e.shaderOutput;
Rect _rect = new Rect(0, 0, _renderTex.width, _renderTex.height);
Graphics.Blit(null, _renderTex, _shaderOutput);
Texture2D _texture2D = new Texture2D(_renderTex.width, _renderTex.height, TextureFormat.RGBA32, false);
_texture2D.filterMode = FilterMode.Point;
RenderTexture.active = _renderTex;
_texture2D.ReadPixels(_rect, 0, 0);
_texture2D.Apply();
Sprite RT_Sprite = Sprite.Create(_texture2D, _rect, new Vector2(0.5f, 0.5f));
return RT_Sprite;
}```
I've been googling around a bit and it seems RenderTexture class may be the culprit here? I found some things saying that its not supported by webGL
what I'm doing here, in short, is turning the output of a shader into a sprite, through a multistep process
is there another way to get a sprite out of a shader ouput that doesn't involve RenderTexture??
or some other way to get this working on webGL?
ooh interesting, I'll take a closer look at this in the morning, thank you
Guys, it's 2023, why did it take my Webgl build 53 minutes to build a small project?
hmm, unfortunately, acoording to this the person fixed their problem simply by including a material in their blit? but I'm already doing that, and having this issue
the material I'm using is being passed in via AfterImageParams and is a material in my assets that has the shader assigned to it
would it make a difference if I got my material from the code?
via Shader.Find and making a new material(shader) ?
ugh, prototyping webGL builds sucks... takes like 5-10 mins to build each time
I tried passing in the shader via AfterImageParams and creating a new Material from it during my method
Shader _shader = e.shader;
Material _shaderOutput = new Material(_shader);
Graphics.Blit(null, tempRT, _shaderOutput,0,0);```
still no good
biggest problem is I still am not entirely sure what part of my code/process is causing it to not work in webGL
is it the RenderTexture class?
is it the Sprite.Create?
is it the Graphics.Blit?
Is it possible to play videos in WebGL? I’m trying to implement cutscenes that‘ll play after each world.
I’ve tried streaming the cutscenes from GitHub, but it almost never works. When it does work, it takes a long time to load.
ok so I did a bit of debugging...
I have 3 MeshRenderers in my scene
The first one is assigned the output of my shader as a material
The second is assigned to the temporary render texture that is created in my above method
and the third is assigned the Texture2D that is filled in by Graphics.blit()
All three of them work in the unity editor in play mode
however, in the webGL build only the first one works
the second one displays as a black box when its empty, and nothing (transparant) when a temporary render texture exists
and the third is just not displaying at all (the texture2D post blit)
so the breaking point here is the RenderTexture...
not only can it not be displayed in webGL, it seems like it just doesnt function at all, or the blit and Texture2D would also work
I'm very confused about this though, because I am using render textures in other places in my project, and those work just fine
The part that seems to not be working here is the Graphics.Blit()
in webGL, its just not copying the material texture to the render texture
omfg I finally got it working.
Sprite MaterialToSpriteWebGLMinimal(AfterImageParams e)
{
Texture2D _texture2D = new Texture2D(e.playerAIRT.width, e.playerAIRT.height, TextureFormat.RGBA32, false);
_texture2D.filterMode = FilterMode.Point;
Rect _rect = new Rect(0, 0, _texture2D.width, _texture2D.height);
Graphics.SetRenderTarget(e.playerAIRT);
GL.Clear(false, true, Color.clear);
Graphics.Blit(null, e.playerAIRT, e.shaderOutput, 0);
RenderTexture.active = e.playerAIRT;
_texture2D.ReadPixels(_rect, 0, 0);
_texture2D.Apply();
Sprite RT_Sprite = Sprite.Create(_texture2D, _rect, new Vector2(0.5f, 0.5f));
return RT_Sprite;
}```
The key here is NOT trying to create a new RenderTexture at run time. Use one that already exists in your assets, and clear it with GL.Clear() everytime you re-use it
webGL appearantly does not allow you to create new RenderTextures at runtime
yes it is possible. Enable streaming option so it could play video while downloading. Also WebGL CANNOT play videos that is not on the same domain as the webgl project. so either play it from your streaming assets or same domain.
Thank you so much for the response. Sorry If this question sounds dumb, but what are streaming assets? I kept seeing developers mention it, but I never really understood what they were.
https://docs.unity3d.com/Manual/StreamingAssets.html
In simple words, you create Folder named StreamingAssets in your project and everything that is inside that folder will be included automaticly in your build. That will also create folder in your webgl build, and all files there will be accessible from inside game.
Please check common practices for webgl accesing of streaming assets.
To read streaming Assets on platforms like Android and WebGL , where you cannot access streaming Asset files directly, use UnityWebRequest. For an example, see Application.streamingAssetsPath.
tho if you will add your files inside that folder on media player path you can just write: https://yourgamelink.com/StreamingAssets/FileName.mp4 and with this you will be able to play videos or what so ever.
with this approach you can create script which generates the path automaticly depending on platform and test it on editor and webgl without requiring extra code editing
Any way to see the current framerate of a webgl build? In editor we can always click the Stats button, but in webgl not really?
Thank you!
you can always implement it with UI
Makes sense. fpsLabel.Text = $"FPS: {1 / Time.deltaTime}", right?
indeed seems very simple
thank
Well, a bit more complex, but you get the idea
Hey guys,
I have a 3D game I was making so far in the PC/Windows workspace, but my eventual goal was to put it on WebGL.
I finally converted to WebGL workspace, and it works fine, no lighting issues or anything like that.
But when things like projectiles/VFX or anything like a new material appears for the first time, it lags the FPS down to like 3 frames, and then it's good again.
Anyone know how I can solve this?
i think you can create new rendertextures... URP in webgl uses RTHandles, which creates rendertextures at runtime
I tried everything I could, did lots of debugging... the point of failure was always creating a new RenderTexture
got around it by re-using an existing RenderTexture
WebGL does not support VFX at all. it is impossible sorry to dissapoint. Only old school particles can be used. Also if you have any system.threading code, that is no go either. so no tasks and etc.
When I meant VFX, I meant visual effects short-form (VFX).
My effects are still purely old particles, sprites, etc.
I don't do any tasks or thread stuff either, so not sure why there's hiccups
My suggestion is, build dev build with autoconnect profiler and open profiler. this way you can see exact code that does that. That will give us more info to help
Hey gang, would anyone have a minute to help me with some strangeness regarding SetTemplateCustomValue and WebGL templates?
Hello, does anyone know why my webgl game doesn't take keyboard input just mouse, it works fine in unity editor, but when i build and test in web it doesn't register any keyboard press, just mouse inputs, im using unity 2019.4
embedded/ videos can totally play on webgl. But there are some hidden rules to follow to make it work. Mainly most people gets wrong, video file needs to be on the same domain,
A) setup your server to support brotli compression.
B) go to your build options-> player options -> publishing options -> disable compression
ahem. As soon as I import mp4 file as asset, Unity already throws warning about incompatibility
In runtime or editor?
editor
try adding mp4 to StreamingAssets folder and tell me if you still get an error. As it does support mp4
and waht error you are getting? What platform you are using? and what asset managment you are using?
For webGL you most likely will want to use webrequest to access mp4 as asset
interesting, in StreamingAssets folder it doesn't even recognize it as video
I am on Windows, Unity is at WebGL
what encoding was used for mp4?
Ohhh this 😄
on webgl you cannot reference file directly
What you need to do, is go to your video player, and change source from video clip to URL. and when url is selected you can actually select file you want.
During gameplay, you will need to write code, that will adapt to your domain and then goes to streaming assets and loads video. or you will need to use webrequest to get media from your own streaming assets folder (or anywhere else IN YOUR DOMAIN)
what would be url for root streaming assets folder?
https://docs.unity3d.com/Manual/StreamingAssets.html
https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html
This is correct way to access your streamingassets folder.
I presonally just sometimes do this: Where I just save my domain link as string or get it from other functions. But I suggest to follow correct way as mentioned in unity docs
string url = $"https://{m_domain}/StreamingAssets/{defaultVideoName}";
I mean.... you will need to put it somewhere to be accessed am I right. While testing webgl you can use locallost. While testing on editor you can write full path on your pc. like C://path/mp4
so... there's no persistent path between editor/local server/and web server?
On all platforms except webgl and android there is. Workaround is to get domain from Javascript on start.
Hi. I'm currently try to reload a scene which has many GLB objects inside loaded using a web request. But the memory is never released by unity if I destroy the object or reload the entire scene. Anyone has a suggestion? Basically the Garbage Collector doesn't work and if I reload many times it goes out of memory. Thank you
I tried setting the resolution to 1920x1080, but the resolution still gets overridden. How do I fix this?
I think the website controls the window size, and Unity adapts resolution to it
I had to switch my canvas scaler mode to this and that fixed it
Then it won't scale it weirdly
Though this gives an issue with positions not being aligned as they should be which is also interesting
So whilst that is fixed now, the build seems to do some real whacky stuff to positioning. Any chance you know the culprit?
Possibly an anchor point problem
I haven't made draggable UIs like that but usually anchor points are what make canvas elements react to scaling or positioning weirdly when the screen size changes
But why is it so wonky in the build but not in the editor ;-;
And how would I go about fixing the anchor point problem
If you change your game window to "free aspect" and try to play when it's at various sizes
If UI elements get wonky in similar way as it does in the webgl build, that lets you tweak and see the results immediately
And confirms that it's a scaling setting or anchor point issue
Anchor points determine how canvas elements adjust to scaling
But it might be due to something else too
It should only ever be at 1920x1080 though
I don't think you can guarantee that when a website handles the playback
which then usually adjusts to different device resolutions automatically
Free Aspect does give the same issue, though in the build it appears to just be 1920x1080
Can I make it so it doesn't do that
It does say it's 1920x1080
I don't think you can, or would want to anyway
Just make the UI properly so it works in multiple resolutions
That's a pain in the bum, and I really have no use for that
It does not need to support any other resolution besides 1920x1080
Why not?
It's purely a small minigame that will just be embedded into a website, with other stuff in it
The game won't be the main focus
I also just do not have the time to develop it that way
The game is fully finished, the build is just wonky
That doesn't sound like a good reason tbh
Resolution-locked web games are absolutely tedious if you have to play them on a monitor that's smaller or bigger than intended
You can full screen it ¯_(ツ)_/¯
Unless you fullscreen it specifically with an FHD monitor, the scaling issues will persist
Scaling is an integral part of UI development, and only really a difficult thing if you don't understand it
It quickly becomes easier once you do
Would it? Hm
It is certainly my agenda to get to that at some point, I currently just do not have the time for that, so I really hope I can just get around it and have the build function like the editor
To force a resolution you'd have to hardcode the frame size to the site
Besides that I don't know what workaround there is to avoid doing the scaling
To force a resolution you'd have to hardcode the frame size to the site
Though the thing is that it kinda is already? Since it does say it is 1920x1080, unless I'm misunderstanding something here
I don't know how to read css but I believe if it was running at exactly FHD size, the UI scaling would work exactly as it does when you run it at FHD in Unity
Okay, so it works fine on my laptop
So there's something wonky going on the the aspect ratio then
Which I don't know how to fix ;-;
I'll have to see what happens when I upload it to itch.io or smth
Even if it works there though, it'd still be nice to somehow fix
The same scaling and anchor settings determine changes for both resolution and aspect ratio
When aspect ratio also changes and not just scale the elements must know if they should squeeze or just move closer/further apart while staying anchored to some relative position of the screen and in what proportion
I recommend practicing it a bit
To make some things for certain, the resolution you set in build options doesnt matter. It will be rescaled depending on your Canvas size. So you will need edit HTML and CSS to make sure the scaling does not change aspect ratio. As different laptops have different resolution and aspect rations also mobiles and etc.
UItoolkit have way more friendly way of working with UI on web, as it follows same css rules just like webpage. And you can more easily control how it scales. I personally set default aspect ratio and resolution, that put scaling to shrink and control parameter choose either Height or width, then at least I am sure that aspect ratio wont change in weird ways.
Regardless this will require you to work with CSS and HTML first, when you are finished with that, then go with Unity stuff.
hi guys, does anyone have any idea how i would use the webgl build with react?
Yeah, you basically create an html tag that points to a defined Unity player component, which has defined locations for the web assembly data. https://github.com/jeffreylanters/react-unity-webgl/
so i'm currently using this, i'm trying to figure out how to apply it to a specific route of my custom domain, any ideas?
for example, i don't want it to just load when i type in www.game.com, i want it to be on www.game.com/play
You need to learn React routing then, to create an endpoint /play in which another html source lives that contains that Unity HTML component
It'd look something like this https://hatebin.com/zpztntmaec
ok so i think i understand the problem i'm running into. Does the react unity webgl require the html file to be called "index"? because i already have an index html file for the existing website
is it possible to just add the route in my existing html file? and put the script part of the code in there?
i dont have any experience with html at all so i'm not sure
so i got it to work but i have one problem now, my header for my website is covering the top of the game.. not sure what to do
is it possible to stream a whole scene from network at runtime?
mesh, and texture, lighting
streaming LOD from high to low, little by little
Maybe with addressables
You will need to use different word from stream. You can load assets from network with addressables, you can load it from low to big as it gives you high control over stuff. So I double on DevDunk suggestion.
Or you can go check WebRTC stream unity rendering for actually streaming rendering. But have in mind that does not work with webgl 😄 you can stream to web and stuff, but not webgl 😄
https://github.com/Unity-Technologies/UnityRenderStreaming
https://www.furioos.com/
Hi All. I am trying to build one of my unity projects to WebGL. But no matter what I do I have not been successful due to the following errors
This is the full output of the first error
If I could I would try without using IL2CPP. For desktop mode I have mono as an option for the scripting backend but for HTML5 I only have default
I have looked in the forums but can't really find the answer I need
Is there anything more in EditorLogs before error? which file it was handling before error, that sometimes is the clue
The 3 errors that appeared on the console are in the first screenshot. The text file contains an expanded view of the top error
I believe the second and third errors are caused by the first one
This is the second error
This is the third
everything else is just script warnings
I am talking about this editor logs, it provides more information about build status with more accurate errors. jsut find build error and check logs that are before error. It is comonly possible to see the file that was beeing compiled there
ah ok you want this
You need to copy it after trying building your build. Because here you have somekind of licencing problems which dont rly have anything with build data
I did
dotnetprofile -> you dont use any DOTS stuff right?
also what version are you using?
not in that project
ok it turns out the problem with the application is that I had c# scripts that were importing functions from a dll file that had spaces in it. I removed the spaces and it built successfully.
I now have another problem when the webgl application tries to call the functions
do I need to install emscripten?
Hey there! I'm working with a WebGL build integrated into a Next.js project with React-Unity-WebGL hosted on Vercel with a Supabase backend. I'm curious what best practice would be for hosting the build files (~150mb rn). Vercel is deploying from our Git repo. Technically, I think I could host our build files on Git, but that seems ill-advised given their size. Supabase does provide media storage. I could probably serve the files from there, though I'm not sure how well that would integrate with useUnityContext in the React-Unity-WebGL package. Would be grateful for any insights or to hear solutions others have implemented!
Hi guys, I'm having issues with the WebGL build of my game, it works fine when built for mobile and desktop but the WebGL build is extremely buggy. Textures are missing and characters are not doing what they're supposed to
Any idea on how I can fix this?
My thinking was to follow what itch.io does. I tried seeing where their games are hosted and to be honest I'm still not sure, but I did find this possibly https://developers.poki.com/
Our full-service platform empowers game developers to find success on web. Get your game out to millions of players and get paid in just a few steps.