#🌐┃web

1 messages · Page 6 of 1

charred briar
#

There's a lot of reasons that can happen, I'm just not sure if you really care to troubleshoot or are more looking to voice concerns about it

#

For instance, a new project, first time build, with a release build, set to gzip, is likely a 20min process. Subsequent builds are less. Debug builds remove stripping and build even faster. Removing gzip is also even faster. You should be able to get that down to a 3 or 4 minute build during development in most unity versions for small (<40mb) projects. Not that 20mins is really all that bad, given you really shouldn't be building often in practice for webgl. Forever to me is hours.

But, no sense going into all of that if you don't really care about the what or why. And I don't really love unity enough to defend it :D. If possible, for web, I usually recommend other web based engines. Just because of the unnecessary loading times and download sizes for the web.

burnt heart
#

Morning all

Getting an error on load of my WebGL game, it happens on two browsers (Edge + Chrome)
It's saying something to do with memory allocation, happens when I run in my VM i use for work and outside of the VM too

I've tried enabling/disabling decompression fallback, even tried with/without the appplication/wasm header

A lot of the information like file paths and URL's are omitted for confidentiality

1st screenshot is the error
2nd is the nginx proxy
3rd is the publisher settings
4th is general build settings

Can anyone offer a pointer on what's causing this please?

TIA

burnt heart
#

nvm got it sorted now

burnt heart
#

hi, so i have a for loop (tried foreach too) to iterate through my array and instantiate some prefabs on a leaderboard.

i've had this working fine in editor, but when building + running it refuses to run the for loop.
i've even tried to just have a basic Debug.Log in there to see and it doesn't show either

again, works fine in editor, absolutely does nothing when running as a WebGL game.
is there something i'm missing for it to like my loop?

for (int index = 0; index < scores.Count; index++)
{
  Debug.Log(scores[index].Score);
  GameObject entry = Instantiate(leaderboardEntry,
  GameObject.Find("LeaderboardBody").transform, true) as GameObject;
  entry.transform.GetChild(0).GetComponent<Text>().text = scores[index].UserID;
  entry.transform.GetChild(1).GetComponent<Text>().text = scores[index].Score.ToString();
}```
#

i've also had the spawn in worldspace as false too and still doesn't work

charred briar
burnt heart
#

it's just refusing to acknowledge that loop and never shows anything, even when I had a debug log in it

charred briar
#

Chances are there is a singleton, non-web friendly network request or some other problem causing the issue.

#

Which may only appear when you go through the whole set of scenes end-to-end in the editor

#

But the loop in of itself doesn't have anything obvious for an issue to me

burnt heart
#

i can go through my games whole loop, loading + playing + submitting score + restarting the game perfectly fine in the editor

charred briar
#

from what I can see, the only way that wont execute is if there is an error, the script is missing, or scores.Count is 0.

burnt heart
#

but this is the thing, there's no errors, the scripts there, and the score count isn't 0

charred briar
#

Actually - that's my guess. Add a ebug log before the for loop that does Debug.Log(scores.Count);

#

That'll at least (hopefully) show a bit more of what is happening

#

if that is zero, then we need to see what Scores is (and make sure it isn't something like a scriptable object, etc). If it doesn't run at all, we know something is happening earlier in the script.

#

trial and error is fun 😄

astral wave
#

From what I encountered it is quite common that order of initialization is different. So my guess you Score list is not ready yet on webgl. try to create it in awake instead of start or create it if it does not exist yet. Also GameObject.Find is very slow, I would never suggest using find instead of referencing it.

fallow hill
#

Hi
While I was making a WebGL build of my game, I encountered a problem; In one of my scenes, I use two cameras to achieve a split screen effect but when I build the game in WebGL, it skips the first display where I have set up split screen and moves to the second display where a third camera is rendering.

I checked building it for windows and it works just fine, the problem only persists for WebGL builds. And NO I cannot edit the index.html file because I'm making my game for another public game site and they only require the build folder

Does anyone no a solution to this?

astral wave
#

Does all cameras have Main camera tag?

#

I had cameras problem when I had multiple cameras and used MainCamera tag to select camera. Because both cameras had same tag, it selected first one. And the first one was different on PC and WEbgl

#

so My guess that you using somekind of search/select method and the cameras list is in different order even if they all starts at the same time.

fallow hill
#

I refer to the cameras as objects by dragging them from the hierarchy into the slot on my script; I am not using tags

#

but it might be because I'm manually changing the display and rect transform of the cameras
if yes then it should work fine if I don't however I am high doubts about this; it won't work but I'll check anyways

#

Okay it actually worked but confused a bit

astral wave
#

welcome to WebGL, confusion here is common feeling 😄

fallow hill
#

I made another scene where i set the cameras to split horizonally(wide cameras; one on top and the other on bottom) and it displayed correctly but in the original problem i had set the cameras to split vertically (one on the right and the other on the left).
It's still confusing tho but I confident that I'll be able to solve it now
Thank you so much @astral wave

astral wave
#

glad to heart that you found where to start! good luck!

fallow hill
#

thanks blushie

fallow hill
#

Solved it!
I was changing target displays to switch between split screens and other displays as

                    camera_01.targetDisplay = 0;
                    camera_02.targetDisplay = 0;
                    camera_03.targetDisplay = 1;

But we don't have target displays in WebGL, so I have to render all the cameras in one display and handle accordingly.

Why this happened: I developed the game first in Windows Standalone Platform then switched to WebGL

hollow vale
#

Hey folks! I've hit a lot of bumps on the road of game development. So, I decided to do something different: I’m open sourcing my casual multiplayer web game Crayon🖍️.

It's plug-and-play🔌 ready for Unity game engine, and I’m excited to see how you'll turn it into something big. To help you get started, I've also included the handwritten blueprints on Crayon's design.
https://madhavagar.gumroad.com/l/crayon

Gumroad

A web-based multiplayer coloring game for team building and friends-hour built on Unity. The source files are distributed under the MIT license. You can download the unity package to dive into the C# code, learn behind-the-scenes of game development, or even make your modifications to publish elsewhere.ALSO INCLUDES- The game designer's original...

burnt heart
#

hi all, back again

don't know if i'm being a dumbass, but having an issue with JsonUtility on my WebGL build
Below is the json string i have

{"scores":[
    {"scoreId":5,"userId":"abc","score":3590},
    {"scoreId":4,"userId":"abc","score":130},  
    {"scoreId":2,"userId":"abc","score":120},
    {"scoreId":3,"userId":"abc","score":120},
    {"scoreId":1,"userId":"abc","score":110}
]}```
this is my C# code```cs
public void UpdateLeaderboard(string scoresJson)
    {
        try
        {
            string json = "{\"scores\":" + scoresJson + "}";
            ScoresData scoresList = JsonUtility.FromJson<ScoresData>(json);
            
            int destroyed = 0;

            foreach (Transform child in GameObject.Find("LeaderboardBody").transform)
            {
                Destroy(child);
                destroyed++;
            }

            Debug.Log("Removed " + destroyed + " items from leaderboard");
            
            Debug.Log(scoresList.scores.ToString());
            
            for (int index = 0; index < scoresList.scores.Count(); index++)
            {
                Debug.Log(scoresList.scores[index].score);
                GameObject entry = Instantiate(leaderboardEntry,
                    GameObject.Find("LeaderboardBody").transform, false);
                entry.transform.GetChild(0).GetComponent<Text>().text = scoresList.scores[index].userId;
                entry.transform.GetChild(1).GetComponent<Text>().text = scoresList.scores[index].score.ToString();
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
        }
    }

[Serializable]
public class ScoresData
{
    public List<Score> scores { get; set; }
}

[Serializable]
public class Score
{
    public int scoreId { get; set; }
    public string userId { get; set; }
    public int score { get; set; }
}
```now, the problem here is that this works completely fine in the editor with the same string, but when it's built and running, the same string refuses to parse. I don't get any error unless i try to do something with the scoreList.Scores property.
i've read up on it a few times and looks like WebGL hates threading, but nothing here is being threaded, the only thing I can think that's different is the fact that the API calls to fetch the data are handled via JS because there's some info the calls need that can only be grabbed via JS

is there something with WebGL and Json parsing I'm missing, or something i've missed in general?
#

the other potential solution i can see is returning the needed info from JS and make Unity do the API call, but this was blocking the game before (was just UnityWebRequests), i'm assuming it hated because of threading?

solar hound
#

I want to open webpage inside unity, Is there any way to do it?

arctic rose
#

google for "unity embedded browser"

fallow hill
charred briar
hollow vale
hollow vale
# charred briar Selling it on gumroad for $50 isn't quite the same as just open sourcing it. An...

Ahh, thanks for sharing your thoughts @charred briar! I appreciate it 🙂 Considering #🌐┃web games are a niche among Unity devs, I felt it would be best to put it here.

I understand your point about open source, which is a common misconception we make in equating open source with all free. However, as you would see, open source refers to the license under which the files are distributed, in this case the MIT license, which is indeed free. And while similar for-profit source codes cost significantly more, the modest price floor I have set is just to cover the time and effort invested rather than earning a profit. Cheers 😄

charred briar
#

If I was to say, create an asset pack for sale, posting it in here is a no no

#

Even if it's web related

#

I'm sure if it was a github thing saying hey I posted the code for X, I'm sure no one would care particularily. But saying you want money for source code (advertising) is against the conduct and belongs elsewhere i.e. #1080140002849214464 - the two places advertising is allowed per the #📖┃code-of-conduct is two archived channels. You could maybe toss it in #1180170818983051344 but that's really not for advertising either.

hollow vale
#

Ahh, right! Again, selling hasn't been my focus. I'm sorry if my message felt that way. Just wanted to put a word out there in case anyone is struggling with multiplayer setup(which I myself struggled immensely with and wasnt clear until I visited some source codes) or any aspect of C# code that they may think they could take cue of from this project.
But i understand you, and feel my messaging could have been more clear and directed towards aspects of code that maybe of direct help, instead of looking like an advertisement. Thanks for pointing that out @charred briar I'll take care of that.

charred briar
#

Saying you open source your game is fine. Linking to a gumroad purchase is monetizing (not just open source).

cinder creek
solar hound
#

https://paste.ofcode.org/NaschTgJRLLqCXwbG5YAsP. Hello friends I am using Application.runInbackground = true; and i want to kepp this coroutine countinue and finish in background but its pause while web app is running in backgound, I am using WebGl build

random talon
#

Found a strange bug on calling a method from the side front-end to the unity webgl app, it gets executed correctly but at the end I get an "undefined", as u can se I've just put a debug.log("END"); at the bottom of the method to check if the undefined was something left in the code but it was not...any idea on what it could be?

#

Ok I get undefined if the method that I call has not code in it 🤔

#

and its a void so it doesnt return nothing

arctic rose
#

That's how the console works. It prints the value of the last line after it's been evaluated. The value of a function call that returns nothing is undefined

random talon
#

so I can consider it normal?

arctic rose
#

yes

vestal cloak
#

@quartz goblet !collab

somber questBOT
still adder
#

Hello, Im trying to host a webGL Build on a react.js website. any one have any tips?

arctic rose
#

If you're having problems with it, describe the issue and ask a proper question. Random tips aren't going to be helpful

random talon
#

Is it possible to modify the index.hmrl in order to have 1 (or 2) gifs when loading the webapp?

charred briar
solar hound
#

Hello friends I am using Application.runInbackground = true; and i want to kepp coroutine countinue and finish in background but its pause while web app is running in background, I am using WebGl build

quartz goblet
astral wave
# solar hound Hello friends I am using Application.runInbackground = true; and i want to kepp ...

I hope someone will know better than me, but you will run into alot of problems when Tab is not active. Websockets dies, connection breaks and etc. And you can control most of those things, as it is up to browser to control your tabs processes. And what most browsers do? deactivate not needed tabs to save power and resources. So only way is to have the tab active, sorry. I also had tons of problems with that, and did no find any universal solutions. But maybe I am wrong or dont know something.

#

tho some people says they have better results if they lock their Application.targetFrameRate = 30; but that just make it less visible, but don't solve the problem fully.

solar hound
#

@astral wave thanks for the answer! I will try this Application.targetFrameRate = 30;

solar hound
#

@astral wave Application.targetFrameRate = 30 is not working for me, I keep the Application.runInbackground = true and when i am on the browser but in different tab runinbackground not working but when i switch to another application like filemanager or other runinbackground working fine.

astral wave
#

from what I understand in different tab application is either pauzed or reduced to to super low frame rate. But you can't control it unless you control browsers code.

solar hound
#

yes exactly I have timer in my application so its slow down when i'm on other tab

surreal shard
#

!cs

somber questBOT
random talon
#

Any idea on what could be the reason for this artifact?
Device is Mac (OS Sonoma 14.2.1)
I've tested my webgl app on other Mac devices and didnt had problems...

astral wave
#

MY guess is scaling. As on webgl it gets random scaling of weird resolutions it runs at. try set same resolution on editor and see if it still acts the same.

charred briar
#

Its also pretty unattractive. It's a neat idea, but the cleanup involved to make it look good enough for commercial use isn't trivial.

cyan heath
#

hi, new here, new to unity and absolutly cluesless on to why my web.config isnt working when i try to host my webgl game on azure (it needs to be azure). gzip compression not working and unconpressed isnt building right eather. I am doing something wrong, thats for sure, not alot of "explain it to me like im five" tutorials out there that arent outdated, i think. Please help me. Thanx in advance! ❤️

arctic rose
#

You're probably better off asking on an Azure or devops server. After a WebGL game has been built, there's nothing special about it from the server's point of view. It's just a standard website.

marble flicker
#

I'm getting this Wwise+Unity error, but googling it results in only one result, and it's a forum post with no responses. Anyone know what's happening?

WwiseUnity: A class has not been registered for the reference platform: Web

UnityEngine.Debug:LogError (object) AkWwiseInitializationSettings:UpdatePlatforms () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/API/Runtime/Handwritten/Common/AkWwiseInitializationSettings.cs:448) AkPluginActivator:Update (bool) (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/API/Editor/AkPluginActivator.cs:693) AkWwiseWWUBuilder:Populate () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/API/Editor/WwiseWindows/AkWwiseWWUBuilder.cs:143) AkWwiseWWUBuilder:Tick () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/API/Editor/WwiseWindows/AkWwiseWWUBuilder.cs:84) AkWwiseWWUBuilder:StartWWUWatcher () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/API/Editor/WwiseWindows/AkWwiseWWUBuilder.cs:330) AkWwisePostImportCallbackSetup:PostImportFunction () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/MonoBehaviour/Editor/WwiseSetupWizard/AkWwisePostImportCallbackSetup.cs:166) AkWwisePostImportCallbackSetup:RefreshCallback () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/MonoBehaviour/Editor/WwiseSetupWizard/AkWwisePostImportCallbackSetup.cs:140) AkWwisePostImportCallbackSetup:CheckMigrationStatus () (at D:/Users/Aryo Nazaradeh/Misc/Work/Games/2024/GGJ 2024 Impact/Impact/Impact_Unity_Game/Assets/Wwise/MonoBehaviour/Editor/WwiseSetupWizard/AkWwisePostImportCallbackSetup.cs:67) UnityEditor.EditorApplication:Internal_CallDelayFunctions ()
#

The people on game audio related forums/servers were also unsure about this

arctic rose
#

Everything I see online about this just says that Wwise doesn't support WebGL

frail flax
#

Greetings folks, i am currently having issue getting audio to work for my Brackey's Game Jam project made in Unity 2022.3.20f1 for WebGL. Made a thread below detailing the issue as well as the steps i took thus far in solving the issue.

astral wave
cyan heath
# astral wave an error text would help more. But most likely you webserver is not setuped to s...

Thanx for the guidance , as i suspected me beeing new to this it took some time to figure out simple stuff but i got to work now. In the webgl build i chose the Gzip compression but with decompression fallback checked, this then requires you to add .unityweb files to the mimeMap on the wen.config file. The same file from the uncompressed WebGL builds example on the unity Server configuration code samples page. This might be to obvious to many but im attaching it for the noobs (like me!) with simular issues 🙂

rocky ferry
#

hi all. I've been trying to build my scenes for WebGL, everything including the game object animations look fine in the build however my videos won't play back. The videos plays back fine in unity but they don't play in the built webgl version. I'm a noob so this is probably something very simple but I can't seem to figure it out. (made my videos by creating a videoplayer and drag and dropping it onto a gameobject -a cube)

astral wave
# rocky ferry hi all. I've been trying to build my scenes for WebGL, everything including the ...

https://docs.unity3d.com/2023.1/Documentation/Manual/webgl-video.html this is worth checking for if you using unity 2023.

and another thing is how you load your videos. Is it URL? or from video file? are you loading from streaming assets?

As with webgl there is a lot of things to consider. CORS (when you load from url that dont have same domain), loading from streaming assets, where it recomended to uiser webrequest to load video.

proper night
#

What is more widely supported for webgl, urp or standard pipeline? I am looking to maximize the number of devices this works on.

#

Also, I saw a lot of conflicting information regarding whether webgl works on phones. I saw it works on high-end ones, does it also work with low-end mobile phones

#

Thanks UnityChanThumbsUp

astral wave
# proper night What is more widely supported for webgl, urp or standard pipeline? I am looking ...

URP, mainly couz you will ant to work with most recent Unity version, as it provides way more control over webgl. URP is just better, tho you will need disable features you dont need. And for performance it really depends on your game. For me biggest problem was memory usage, as expecially iPhones have super small limits (~300mb) after which it will keep restarting or not load at all. Phones after iPhone X have way less problems. But if you want it to run on as many devices as possible you will be better with PlayCanvas or Three.js, or babylon.js as their performance is way better than Unity webgl (also memory limits is higher for some reason there as well).
In short: if amount of devices matter, don use Unity webgl. If quality and content matters, use Unity and URP.

rare quail
#

Hi.I have video playback problem on webgl.I did almost everything but the video was not played at all.I changed the video codec to H.264 or webm or reduced the size of the video to KiB .Also I always use URL option,but still the video did not play.Please help me I really don't know what to do.

astral wave
#

URL option is also scuffed. as there might be problems of CORS, aka loading video from different domain will be a big NO NO.

#

also video clips are not supported at all.

rare quail
#

void Start()
{
_videoPlayer = GetComponent<VideoPlayer>();
string videoPath = System.IO.Path.Combine(Application.streamingAssetsPath, videoName+".mp4");
_videoPlayer.url = videoPath;
_videoPlayer.Play();
}

astral wave
#

it will not work. Play needs to be called after user interaction with your application ( touch, click). Well if it is muted then it should work on chrome.

rare quail
#

So I will test this

rare quail
astral wave
#

what resolution of that video? WebGL videos is very demanding. but it should not be that bad. On player settings did you enable Run in the background option?

rare quail
#

Its size is 52 kb

rare quail
rocky ferry
clear grotto
#

is there any way to limit the editor to single thread to simulate the browser so i can test there instead building to webgl each time only to realize the methods don't work blobsad

sweet oriole
clear grotto
#

it's mainly my primetween methods

sweet oriole
clear grotto
#
    private IEnumerator AnimateValueChange(float start, float end)
    {

        yield return new WaitUntil(() => ReelsController.Instance.AllReelsReady());
        Sequence colorSequence = Sequence.Create(cycles: -1, CycleMode.Yoyo).Chain(Tween.Color(_userBalanceText, endValue: Color.yellow, duration: 0.1f, ease: Ease.Default)).Chain(Tween.Color(_userBalanceText, endValue: Color.white, duration: 0.1f, ease: Ease.Default));

        animateTextIncrease = Tween.Custom(start, end, duration: animationDuration, onValueChange: newVal => _userBalanceText.text = newVal.ToString("F2"))
        .OnComplete(() =>
        {
            colorSequence.Complete();
            _userBalanceText.color = initialColor;
            _userBalanceText.text = end.ToString("F2");

        });

    }
#

in editor it works great, but in webgl does nothing thisisfine ...

sweet oriole
#

PrimeTween is truly multiplatform with no exceptions. ...
Should be fine.

clear grotto
clear grotto
# sweet oriole UniTask might be a nicer alternative

that looks awesome btw. when i'm done building the basics i'm definitely saving that to use in refactor.

after a bunch of Debug.Logs to browser console i tracked it down to event not firing when it's supposed to like it does in editor ... atleast i can go to sleep now knowing where to look tomorrow . thanks !

charred briar
sweet oriole
charred briar
rare quail
clear grotto
#

i finally found the culprit... i'm so confused on why it happens . for some reason this setter method doesn't work in webgl (it works in editor though)

[System.Serializable]
public class Result
{
    public static event Action<float> OnPrize;
    public ExitStorage exitStorage;
    public IProcessedLine[] lines;
    private float _prize;
    public float prize
    {
        get => _prize;
        set
        {
            UnityEngine.Debug.Log($"Result.prize, value = {value}");
            _prize = value;
            if (_prize > 0) OnPrize?.Invoke(_prize);
        }
    }
}
#
[System.Serializable]
public class Result
{
    public static event Action<float> OnPrize;

    public ExitStorage exitStorage;
    public IProcessedLine[] lines;
    public float prize;

}

this works though 🤔 🤷

high patrol
#

someone's workin at IGT lol

#

I have used UniTask in the past successfully to port over multithreaded code to use unitask instead. We might not have to worry soon since Unity is totally going to support multithreading for webgl sometime this decade maybe

stoic tinsel
#

Awaitable also works great as a replacement for task<T> on webgl if you just want async and await not actual threads.

stoic tinsel
#

Question about multi threading… who here has multithreaded a heavy web app in emscriptem c++ or JavaScript and how well does it work on chrome on an average PC (or on a phone?)

#

I mean… we’re talking about web browsers, which aren’t primarily focussed on high performance compute. Assuming unity DID fix webgl c# multithreading to the maximum extent oosssible, do we know that that extent is equivalent to multithreading code ina native app (similar possibility of. Umber of worker threads, timeslice etc?) or is it more like “chrome only lets you use 4 physical cores no matter your PC core count” etc

#

I’m thinking about doing rhe test myself but wanted to ask first.

outer wave
#

What number of batches should I be looking at with webgl?

#

Also, static batching vs gpu instancing

rare quail
#

What is this error in Unity when building for webgl and how can I solve it:
Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js: undefined symbol: ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5 (referenced by top-level compiled C/C++ code)

silk maple
#

I found out that there is a way to run Java code even when the Chrome browser tab is disabled.

However, I found that in the Unity webgl build or the 2023.3 version of the web build, no update works when the tab is disabled even though RunInBackground is turned on.

Is there any way to solve this? I would like to modify framework.js but it is too complicated.

#

Why does runInBackground not work for web builds, even though it obviously has a way to run Java code even when the tab is inactive?

sullen sandal
#

Trying to load textures into my Character Select Screen but doesn't load them in WebGL. It's a custom character animator that uses Coroutines to animate characters through a list of PNGs. It looks through a folder in Assets that has these PNGs and loads them in the game.

In the picture I manually put a button with no character. In the editor it shows both the manually button and the character but in webGL it's having trouble loading my character in my Asset/Characters/ folder.

Does anyone know what's wrong here and why it's not loading the character PNG in web.

sweet oriole
velvet warren
#

I'm hoping someone can help me with some confusion regarding WebGL and multi-threading. My understanding is that code using System.Threading will not work, and Jobs may or may not work (which is it?).

However, I am using Parallel.For and several IJobParallelFor structs in some code (compiled into a DLL), and when I build to WebGL everything works fine. My use of Parallel.For is very simple; does Unity somehow convert the code to a normal For loop, which is why it works (which I would be fine with)?

#

My test was on 2020.3.37f1 if that matters

sweet oriole
velvet warren
sweet oriole
velvet warren
quasi adder
#

Hello ! I'm finishing my first game that I would like to put on a web page. However, I don't know much about cybersecurity at all and I'm afraid some of my friends will try to cheat/break the game. Is it possible to break a unity game via web or you have any recommendations for minimal protection?

sweet oriole
quasi adder
#

There's just a leaderboard, I looked up a youtube video to do it (I'm a total beginner) and I'm worried if its possible to send requests to cheat (sorry for my english 🥲)

astral wave
astral wave
# quasi adder There's just a leaderboard, I looked up a youtube video to do it (I'm a total be...

You out of luck. Only way to protect directly is to have full server authority over all clients actions. But there still a ways to make it secure, mostly to create some specific checks if that update is possible. For example you can see only score in leaderboards, but when you send new score you send duration of session as well. And on API you check if that score is even possible with that time. Aka dirty methods.

But more about your question: is webgl easy to hack? never tried, dont know. But it is harder than PlayCanvas or native JS libraries as most of code is translated in not so user friendly machine coding. But I know that with chrome dev tools you can do quite a lot. For example intercept websocket message. And with some coding you can send fake messages which API or what ever is your server is easy to trick. But as first game I would not think too much about it.

astral wave
untold field
#

How can I solve the microphone error in Unity WebGL when hosting through AWS? I encountered this problem; while hosting locally, no error occurs, but it arises when hosting through AWS

silk maple
#

Where is entry point for 'update' runtime in the web build's framework.js?

untold field
#

How can I obtain the framework.js file?

astral wave
# untold field How can I solve the microphone error in Unity WebGL when hosting through AWS? I ...

first of all open browser console, for more accurate error code. Second of all, make sure your AWS is https, as without secure connection you wont be able to use any devices. Local host is exception for that rule. framework.js wont be readable, it is mostly generated machine coding. If you want full stacktrace errors handling, set build to develop mode and on publish settings changes logs to full stack trace.

astral wave
untold field
#

@astral wave I Thougt problem is web is not secure i am i right?

astral wave
untold field
#

Okay thank you for Clarification

silk maple
#

If framework.js is using for updating runtime, then i can fix it to keep update when tab is disabled

astral wave
# silk maple Just want to keep update when browser tab is disabled

on Player settings -> resolution and presentation you need to check run in background. Browser controls what runs and does not run when tab is disabled. So you cannot actually control that 🙂 with this option at least it will run at 1fps or whatever browser want it to run.,

silk maple
#

No logs were recorded while the tab was inactive.

astral wave
astral wave
silk maple
silk maple
astral wave
#

just make sure: have you enabled Run in background?

silk maple
silk maple
#

I did all kinds of testing

#

From changing browser settings to modifying JavaScript.

#

As a result, I was able to send a message to Unity using JavaScript in the unityframework loader part of the html, but there is a problem with this.

#

Only this method could update Unity update, fixedupdate, etc.

#

So I think framework.js among the web build files created by Unity can solve this problem.

astral wave
#

Okay there is one more workaround that helps some people. Set target frame rate at 30 or lower. Some browsers then lets you run it. But this is just workaround. short anwser: different tab = dead tab

silk maple
silk maple
#

And I wonder if you've ever done the test I mentioned. If you are sure that runInbackground = true solves this problem, you should at least test it.

#

I also tested with other players to see if this was just my problem, but the results were the same.

#

There is some code in framework.js that is responsible for updating something. The problem is that it works with setInterval, and I remember it didn't work well when the tab was disabled.

astral wave
#

you clearly know it better than me. I am not here for fighting. If you want change how Unity webgl and browsers tabs works you are free to do so.

silk maple
#

Even the Unity guys here are confident that runInbackground will solve it, but as it turns out, it hasn't solved the problem in over two years.

#

Since Unity has decided to support web in the next version of Unity, this problem will definitely be resolved then.

#

But what about older versions of Unity?

#

But thank you for your help so far.

astral wave
#

It is not UNITY PROBLEM. Play canvas works exactly the same. The tab is inactive, update does not work. It is browser problems and you cant change it. so my answer from the start you are out of luck and cant run logs on update. As how it works it differs from browser to browser. Some browsers stops it completely. Other reduced frame rate to super low. all for better performance.

#

nad yes I tested all debuging for it for 3 years now. WebGL sucks as you need to follow more rules than any other platform.

#

I jsut gave you solutions that helps with some of problem regarding that.

silk maple
#

I don't know much about js. Is Play Canvas used in Unity rendering?

astral wave
#

For example. Audio works only if you press run in background. but update functions don't work. Or some coroutines can work in background. For example if you have coroutine to run code every 10 seconds you will get response ONCE. it will finish but never start again until you will make tab active again.

astral wave
silk maple
#

However, I have already succeeded in sending messages to Unity in the background at a certain period of time. What this means is that the Unity team can call update in the same way.

#

fixedUpdate, which runs during the same cycle, can definitely be solved this way.

#

I implemented this in the Unity load section of index.html and was successful. However, there was a bit of a sync problem with Unity's actual fixedupdate function call.

#

So I think this was clearly a problem that could have been solved.

#

The sync problem occurs because the call cycle of unity's fixedupdate and the call cycle of fixedupdate that I executed by sending a message through index.html are different.

#

What is certain is that update and fixedupdate can be called as messages through JavaScript in index.html, and this fact alone does not mean that Unity's disabled tab problem is an unsolvable problem.

fading lantern
#

Hello! My Unity code makes a request to access an online leaderboard. However, the issue is that users can see the URL request on the site using the inspector. Is there a way to ask Unity to hide it?

arctic rose
#

No. Unity is not showing the request, the browser is

fading lantern
#

there is no way to hide it in the browser?

arctic rose
#

correct

fading lantern
#

ok ty

sullen sandal
# sweet oriole Addressables or streaming assets is probably what you are looking for <https://d...

for Streaming Assets, Directory.GetDirectories wouldn't work right? what would be the equivalent to that? Also is this correct on what I'm trying to change?

//filePath = Application.dataPath + "/Characters/";
filePath = Path.Combine(Application.streamingAssetsPath) + "/Characters/";

string[] characterDirectories = Directory.GetDirectories(filePath);

for (int i = 0; i < characterDirectories.Length; i++)
{
    CharacterSelectButton spawnedPrefab = Instantiate(buttonPrefab, contents);
    spawnedPrefab.Intialize(characterDirectories[i]);
}
sweet oriole
# sullen sandal for Streaming Assets, Directory.GetDirectories wouldn't work right? what would b...

On WebGL, Application.streamingAssetsPath returns a HTTP URL that points to the StreamingAssets/ path on the web server. For example, http://localhost:8000/unity_webgl_build/StreamingAssets/ is returned when your application is running against a local development server.

On Android and WebGL platforms, it’s not possible to access the streaming asset files directly via file system APIs and streamingAssets path because these platforms return a URL. Use the UnityWebRequest class to access the content instead.

#

I doubt Directory methods will work and I'm not sure if you can get directory/file listings without some sort of additional mechanism on the web server. Managing your own list of paths is probably the most portable way to do this.

placid hatch
#

hi guys. for some reason i cannot see my webgl output in chrome console, any ideas?

arctic rose
#

What is "webgl output"?

placid hatch
#

like debug.log

arctic rose
#

Show a screenshot of the console

placid hatch
#

well theres nothing to show

#

works in editor, not in browser

arctic rose
#

Yes but the screenshot shows if you have something disabled there or something else out of the ordinary

#

also check that the player log is enabled in WebGL build options

placid hatch
#

i dont see that option

#

never had this issue before, always worked.

#

oh i just remembered i removed logging from logging.js!

#

because it was spamming console lol

marble bough
#

Hi guys I need some help with building webgl. it started failing recently with an error that i have never seen before. emmscript python.exe failed to run a command. has anyone experienced similar issues? I can provide logs if necessary

astral wave
tribal relic
#

Hey guys, curious if anyone has integrated a web wallet with webGL game, would love to see some examples or hear recommendations. I'm interested in allowing a player to claim an NFT at the end of a level, using Needle Engine.

outer wave
astral wave
outer wave
#

I'd assume gpu instancing is the clear winner over dynamic batching in this regard

astral wave
#

what we were doing was static objects went with static batching. Dinamic ones got gpu instancing and srp batcher was on on quality settings. Or you are working not on urp?

#

tho cant remember why this decision was made, as it was quite long time ago. well for me 350 batches is quite too much for webgl. but just my personal opinion.

outer wave
#

I've got a few extra cameras and some stenciling so I've got some extra rendering going on, but just trying to see how well webgl holds up

errant cipher
#

Anyone know what this WebGL error is trying to tell me?

RankException: Only single dimension arrays are supported here.
at System.Array.Copy (System.Array sourceArray, System.Int32 sourceIndex, System.Array destinationArray, System.Int32 destinationIndex, System.Int32 length) [0x00000] in <00000000000000000000000000000000>:0 

function _JS_Log_Dump(ptr, type)
  {
      var str = UTF8ToString(ptr);
      if (typeof dump == 'function')
          dump (str);
      switch (type)
      {
          case 0: //LogType_Error
          case 1: //LogType_Assert
          case 4: //LogType_Exception
              console.error (str); <== THIS IS WHERE THE ERROR IS POINTING TO
              return;
  
          case 2: //LogType_Warning
              console.warn (str);
              return;
  
          case 3: //LogType_Log
          case 5: //LogType_Debug
              console.log (str);
              return;            
  
          default:
              console.error ("Unknown console message type!")
              console.error (str);
      }
  }
charred briar
#

But it's saying to use a single dimensional array SomeArray[] not a multidimensional array SomeArray[][]

errant cipher
#

I don't even know where to start looking.

astral wave
outer wave
#

Why does there seem to be no option for async loading with webgl? I just want a responsive loading screen instead of my whole program locking up for multiple seconds.

#
    private IEnumerator LoadSubstringBundle()
    {

#if UNITY_WEBGL && !UNITY_EDITOR
        UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(assetBundlePath);
        yield return request.SendWebRequest();

        if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
        {
            Debug.LogError(request.error);
        }

        else
        {
            // Get downloaded asset bundle
            bundleRef = DownloadHandlerAssetBundle.GetContent(request);
        }
#else
      var assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundlePath);
      yield return assetBundleCreateRequest;
      bundleRef = assetBundleCreateRequest.assetBundle;
#endif
    }```
Actually, that seems to work, I'm just not too sure why. I guess the files are loaded after the web request?
#

I expect to need LoadFromFileAsync but you cant use that with webgl

outer wave
#

https://i.imgur.com/cV502DH.png
Can anyone tell me how to rid of this bottom padding? I've tried completely wiping out the style sheet and it continues to show on the player. It'll even add the text of the build in the space if I were to do that as well which is worse.

astral wave
marble bough
#

Failed running command "C:/Program Files/Unity/Hub/Editor/2019.4.39f1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe" -E "C:/Program Files/Unity/Hub/Editor/2019.4.39f1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten\emcc"

I get this error when building for WebGL anyone had this issue? this also happens on completely clean project Reinstalling unity changing unity version and deleting tmp and libraries did not help

outer wave
#

I guess the problem mostly is that stuff that you cant naturally yield with via coroutines isn't possible with unitask

#

like zipping methods

astral wave
#

async should work without uniTask. But Tasks them self does not finish up on webgl. but I Have not met any problems on UniTask yet. maybe yours is very specific task that fails. In general webgl is just traps field 😄

outer wave
#

ah, is that the problem? I don't care about multithread, I was just looking for a way not to block the main thread but also loading my files.

#

cant yield when using methods like ZipFile, so that was making it tricky. In the end, I should just be using asset bundles anyway since it just makes more sense.

astral wave
astral wave
arctic rose
#

<@&502884371011731486>

modern plaza
arctic rose
#

You'll find out soon enough

astral wave
wise plover
#

Anyone know how to enable the profile:me scope for itch.io with a WebGL build?

sly wave
#

by activating the stacktrace for errors as in the image below, are the performance of a unity webgl build worse with the console closed compared to not activating the stackatrace at all? Thank you.

astral wave
frosty loom
#

Im trying to convert my game in WebGL, but I keep getting this error and my player settings wont show, any tips?

charred briar
astral wave
thin stone
#

I only seem to get an issue with my video player starting off black and starting slower on Firefox, it seems to be okay on chrome and edge. Would anybody happen to know if there's some kind of secret to Firefox optimisation?

astral wave
# thin stone I only seem to get an issue with my video player starting off black and starting...

In general video on webgl is .. well special. But it can also be caused by different order of execution, similar like there are cases when game works differently on different pc depending on your code. Expecially when you have find functions or alot of stuff happening on start which depends on each other. Another of causes with black screen especially, that your screen does not get dirty tag at the start. In order to solve that, when video actually starts you need to make texture dirty so it can correctly update (as sometimes if you start video, but video data is not ready yet, it will become black screen and even if on next frame there is video data it will not update. you only need to do it once after video start, after it video gets dirty status correctly.)

Also it could be like one of 9000 other webgl problems 😄

unreal scarab
#

Wait how do I convert my HTML game into a unity game.

#

I tried my own coding for once that loads .html code but. Still dont work

using UnityEngine.UI;

public class MonkePaint : MonoBehaviour
{
    // Embedded HTML content
    private string embeddedHTML = @"
        <!-- Testing the loader -->
        <div>
            <h1>Test</h1>
            <p>Test.</p>
            <p>Test.</p>
        </div>
    ";

    public Transform parentTransform;

    void Start()
    {
        GenerateUI(embeddedHTML, parentTransform);
    }

    void GenerateUI(string htmlContent, Transform parent)
    {
        
        
    }
}
``` (Quick hint im tryna make my .html game into a game in unity)
astral wave
#

You will need to be more specific. as now I am not sure, are you chasing something that is completely impossible, or something that is plausible

sweet oriole
unreal scarab
unreal scarab
sweet oriole
unreal scarab
charred briar
#

Although there are far easier ways (than recreating it in Unity) to build and publish a web app or service into mobile.

charred briar
#

You can package web services and web apps into APKs without Unity if you want.

unreal scarab
charred briar
#

There are third party plugins you can also buy in the asset store to.let you create an embedded browser view in Unity. But it would just be a really ugly solution that way

upbeat kayak
#

I am build and running my webgl project and I keep getting this error and my Textmeshpro text wont load anyone have any idea why this happens or how to fix it?

MORE CONTEXT

It seems that it is the text that is causing the issue, I am using a custom font but its the text that does not load. Anyone have any clue why this would be?

wind hatch
#

Hey, I'm having trouble while using the controller that only happens in WebGL. No input is working, it's as if the controller is not detected at all.
No issues with standalone builds.
Any insight on what could be the problem? I'm using the new input system btw

sweet oriole
wind hatch
astral wave
wind hatch
wind hatch
sweet oriole
#

The new input system was designed to work with devices which the input system doesn't necessarily have mappings available, but the developer can provide for. It's not necessarily something you want or need to do, but the point is that the input system exposes a lot of information that could be helpful for input device debugging.

#

Manual has several mentions specifically for WebGL input support.

wind hatch
plush ledge
#

Hello, I am trying to use this javascript function to print the Useragent information that the browser has for me. My function looks like this GetUserAgent: function() { var UA = Pointer_stringify(navigator.userAgent); return UA; },

plush ledge
#

Note: UTF8ToString(message) also not working.

astral wave
#

also if you build lib file, make sure it is enabled on webgl platform and disabled on others

plush ledge
astral wave
plush ledge
#

I Tried JSON.stringify(), i think i might be doing something completely wrong, would you like a closer look at my project on the unity Website forum ?

plush ledge
astral wave
astral wave
#

as js will not run editor.

plush ledge
#

@astral wave I wasn't aware, and I'll probably use it, however, figuring out how I might troubleshoot the issue.

autoAddDeps(DeviceInfo,'GetUserAgent')

autoAddDeps(DeviceInfo,'GetScreenWidth')
doesnt do this, ive tried taking away the 'GetScreenWidth' function from both the c# code and the plugin

#

Yes, i'm aware of the Preprocessor directives, they didn't change the results either 😦

#

I did some reading and I was trying to figure out things such as how I would see if this plugin is making this GetUserAgent Result, an environment variable somehow that i can make use of in unity C#, because i was reading something about C/C++ interop and i probably read it incorrectly but learning something along that line so i can pinpoint the issue past i cant print the information is what im looking for

#

I'm hoping that it isn't C# posting it in some odd format or characters that are there but i can't see.. which is unlikely because its unity C# so im not banking on that, but right now, im almost convinced that Java Is returning something that Unity cant use in the manner that im trying to use it, but i REALLY want to know why badly.

#

.jslib is something i haven't had very much fortune with finding out information on. But im hoping everything im doing in that file is correct because my "GetScreebWidth is printing properly

plush ledge
plush ledge
#

New information from me.
i know its Unity C# that is not allowing me to Call the Function now. Because i see this function in my browser, as what i think is an environment variable.

#

I also did some research on string Marshalling.

plush ledge
# astral wave also you can try making sure to use same approach as https://docs.unity3d.com/Ma...

(Solved.. I Indeed just needed to read and follow simple instructions Better. )

autoAddDeps(DeviceInfo,'GetUserAgent')

autoAddDeps(DeviceInfo,'GetScreenWidth')
were actually necessary

However, in the docs, it says you handle string in this manner:
StringReturnValueFunction: function () {
var returnStr = "bla";
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
return buffer;
}
where my string would be navigator.userAgent instead of "bla".
the first time i failed to understand what I was being told because, i've never read ANYTHING about buffers, so my **** *** just looked at this like, I don't even know what this thing is saying, and didn't do this. A worthy punishment for failing to read thoroughly.

pure crane
#

I noticed WebGL apps, when loaded on android will ask to install, but when it does, it uses a generic icon. Any idea how to change it?

glacial yacht
#

Hi guys.

wet grail
#

@glacial yacht Has nothing to do with Unity

waxen shadow
#

Hello Everyone,

I need help regarding an issue I'm facing.

I'm creating a webGl game for Smartphones, and I want to add a Full screen function when the user clicks for the first time. But the unity's full-screen button is not working in IOS Smartphones and I also tried different methods, but there is still no progress.

Can anyone please help me with this?

Thank you

arctic rose
#

iOS Safari doesn't support fullscreen

waxen shadow
arctic rose
#

no

#

Well, if the user makes a desktop link with the the "Add to Home Screen" feature then the website can run in fullscreen. But the website itself can't initiate fullscreen

waxen shadow
#

Okay, thanks for your help

waxen shadow
arctic rose
#

Google for "ios pwa tutorial"

orchid bridge
#

:(

halcyon hedge
#

@orchid bridge just embed the index.htm unity page gives u in the iframe

orchid bridge
#

how do i embed.

#

I haven't used HTML in a long time.

halcyon hedge
#

where are you trying to add this webgl

orchid bridge
#

my thingy

halcyon hedge
#

that doesn't answer

orchid bridge
halcyon hedge
orchid bridge
#

HTA (Application in which you can program using HTML).

halcyon hedge
orchid bridge
#

idk how to program apps..

halcyon hedge
#

why do you need to "program an app"

orchid bridge
#

also do you know where i can report this?
some kid kept saying godot is better.

orchid bridge
halcyon hedge
#

ok , this is a waste of my time

#

goodluck

lilac rose
#

When I try to publish my game, it loads to 90%

sweet oriole
lilac rose
sweet oriole
#

Depends on your browser. I would look it up.

hardy bear
#

Hello i'm new to unity and i just basically started creating stuff by following the unity course online, i just finished lessons on how to make audio tracks play in the bg and generate 3d sounds. after all that, the course asks me to build it with WebLG and then publish it online by using the WebLG publisher. The project i've made is a 3D Cross-platform URP as requested, and i've everything i had to and i had no problems with that BUT, when i build it, if I select build and run the project works perfectly fine in the site but, if i close that window and try to open it again with the index.html inside the folder i've built that in, it doesnt work and it gives me an error which is:

"Failed to download file Build/Dududu.data. 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 have no idea how i can fix this problem, i tried to use different approches like, building another scene, clean building it multiple times AND even redoing all of that project from scratch and rebuild it again but nothing has worked.

i am sorry if this sounds like a dumb question but i'm not even that good with compsci overall, im still in hs and i just started using unity for fun and i'd like to continue obviously but i still have no idea what is wrong with that build because i dont think i've made anything different from the last time i published a project making it work in any scenario.

I hope that someone will be patient enought to help me out with this 🙏

wet grail
hardy bear
#

idk it these errors are correlated with the build or smthing like that

wet grail
#

Unity's site is somewhat weird, it breaks on first run. Try refreshing the page with Ctrl+F5 .

#

If that doesn't fix it look up what those errors mean

hardy bear
#

i moved on, it's surely a bug correlated to me importing some other assets that are probably not public so ill avoid that and that it

vast radish
#

Hi guys. Anyone get copy and pasting working on webgl?

wet grail
vast radish
#

Thanks man

muted bolt
#

im having some webgl lighting issues everything is much dark on the built webgl deployment, any ideas?

#

issues happened when i switched to urp

astral wave
muted bolt
weary jackal
#

i am getting this in local server no water or grid ..?

astral wave
#

is there any error on browser console? are you using something like VFX?

weary jackal
#

no error on browser console. and only water surface turns like this grid is still rendering

astral wave
#

as if shader would not be compiled correctly during build, it would be invisible instead of totally black

rapid oasis
#

Hello guys, I was wondering if there is a way to make the webgl build always use the same local host port as I can see that sometimes it varies slightly, and I need to save and retrieve local data from the browser. Thank you

weary jackal
weary jackal
rapid oasis
weary jackal
#

Idk abt that but yeah this is two step process. U have to build it and run the command inside the build. But yeah it gets ur single port

rapid oasis
#

Kk thanks dude I will look into it

astral wave
# weary jackal I m using Aqus lite asset from store

oh so you working not on URP? maybe you need to enable depth buffer in project settings or something? Common error is that webgl by default uses different rendering settings profile (you know, low, medium, high), which might have disabled feature that shader uses, like depth buffer or others. Try setting same default quality for all platforms.

astral wave
light rampart
#

hi there
does anyone know how my webgl build wouldn't have the Builder.loader.js file without any errors?

#

it's complete gone on build, but I get no errors during the process and the file is necessary

weary jackal
weary jackal
frank herald
#

Hello everyone, my team and I are encountering challenges with our Unity WebGL build. Our aim is to develop a build suitable for running on both mobile and PC browsers. We're utilizing Unity version 2022.3.5f1.

Presently, we're encountering inconsistencies upon launching the application. At times, we encounter prolonged loading screens, while in other instances, certain in-game scenes fail to load. Additionally, we've noticed visual glitches where our canvases fail to render properly until a page refresh.

We've conducted tests across various devices, platforms, and browsers, yet we're still experiencing inconsistencies across builds.

If anyone within the community has insights or advice on this matter, we would greatly appreciate it.

astral wave
# frank herald Hello everyone, my team and I are encountering challenges with our Unity WebGL b...

Running both mobile and pc is challenging. Unity webgl havee very limited memory usage on mobile devices (350~mb RAM regardless on device memory), expecially on iPhones. Which forces to use a lot of optimisations on that end. For example making sure all images is encoded in ASTC if you want it to run on android and iPhones (https://docs.unity3d.com/Manual/class-TextureImporterOverride.html) , or pack textures separately for each device. Aggressive memory management with Adressables also helps. Visual glitches on UI also appeared on our project when project was running at the edge line of memory limit (we were using uitoolkit) expecially on iOS devices.

In short it is hard and have tons of limiations. If mobile is your main focus, maybe switching to Playcanvas or other native methods are better. But if main focus is PC, I wish you best luck and stay strong with Unity!

gaunt hollow
#

Good day
Anyone experienced with
Module.dynCall_viiiii is not a function
at XMLHttpRequest.http_onload
error on unity6 webgl build , webassembly is enabled?

sweet oriole
gaunt hollow
signal turtle
#

Hello! I have a 3D game that I published to Itch in a WebGL format. This game is running very poorly and I was wondering if anyone had any tips and suggestions to optimize my game

astral wave
# signal turtle Hello! I have a 3D game that I published to Itch in a WebGL format. This game is...

Compress all textures with unity compression tools. It save quite a lot of VRAM. Bake occlusion culling maps and use that. Install addressables and load only things you need, not every single scene into memory. Check models to be as low triangles count as it can be to fit your quality requirements. Play with quality settings (also suggest leave only one quality setting for webgl, otherwise shaders are compiled for all quality settings.). Play with quality and render pipeline settings (reduce shadows or disable them at all). and finally, dont use webgl :DDDDDDDDDDDDDDDDDDDDD

signal turtle
astral wave
potent tendon
#

I'm facing a problem with the WebGL Build, when I run the game on Unity Editor, the text "Fill The Bowl" is positioned exactly within the position where I wanted to but after Building WebGL, and when I play in the Unity Play, the text's position initially when I run the game is positioned wrongly and when I play the game and return to home screen, the text is aligned properly. Can someone please help me fix this issue?!

edgy mulch
#

the one that looks like this

potent tendon
#

I set the Rect Transform position to top, and then again I positioned the text, and play tested after WebGL build but still facing the problem

edgy mulch
#

I see that your text is floating up and down, how did you set the position of your text?

potent tendon
# edgy mulch I see that your text is floating up and down, how did you set the position of yo...

First in the script Start method, I've set the position of the text to it's current position and then from the current position to Make it floating, below is the code snippet

void Start()
{
initialPosition = fillTheBoxText.transform.position;
{

void FloatFillTheBoxText()
{
if (initialPosition == null)
{
Debug.LogWarning("initialPosition is not initialized yet.");
return;
}

    float yOffset = Mathf.Sin(Time.time * textFloatSpeed) * textFloatHeight;
    fillTheBoxText.transform.position = initialPosition + new Vector2(0, yOffset);
}
#

And I've used the FloatFillTheBoxText() in Update method to make it flow

edgy mulch
#

the problem here is that using transform.position to set the position does not scale with screen size, so users with different screen sizes may see different things

#

one sec

#

i was thinking that you can make the title text a child object of another object, then use transform.localposition instead

potent tendon
edgy mulch
#

webgl things 😵
you could make a quick patch where the game starts off in another scene, and have it immediately load in the title screen

potent tendon
potent tendon
# edgy mulch webgl things 😵 you could make a quick patch where the game starts off in anoth...

void Start()
{
initialPosition = fillTheBoxText.transform.position;

    buttonInitialScale = playButton.transform.localScale;

{

void FloatFillTheBoxText()
{
float yOffset = Mathf.Sin(Time.time * textFloatSpeed) * textFloatHeight;
fillTheBoxText.transform.position = initialPosition + new Vector2(0, yOffset);
}

// Method to perform zoom in and out animation for the play button
void ZoomInAndOutPlayButton()
{
    float playButtonScale = Mathf.Sin(Time.time * buttonZoomSpeed) * buttonZoomAmount;
    playButton.transform.localScale = buttonInitialScale + new Vector2(playButtonScale, playButtonScale);
}

If you look at the methods above, they are almost same but the way they function differs and there's no issue with the Button at all as it's showing in the position as intended

edgy mulch
#

whats the canvas scaling mode?

#

if its scale with screen size make it biased to height instead of width

potent tendon
edgy mulch
potent tendon
# edgy mulch

Just a noob so have lodz of questions, how will this help fix the issue? Because, as you can see, the issue I'm facing is only upon loading the game, the issue is getting fixed upon playing the game and returning to menu screen. I'm wondering what could be causing the issue here

edgy mulch
#

this is probably a bug

#

what unity version are you on so I can replicate it?

potent tendon
#

2022.3.22f1 LTS

sweet oriole
# potent tendon But that's a patch 😢 can't we fix this issue? If you look at the play button, ...

I would try to delay grabbing of the initial position to see if it's some execution order issue with Canvas layouting. Modifying RectTransform's anchored position might also behave better. Could also try keeping track of just the offset and add/subtract it from whatever the current position is to play nicer with canvas scaling.
You can test some of these behaviours better in editor if you set your game view to free aspect and resize the window in play mode.

potent tendon
potent tendon
#

So, I just built and run the Windows version of the game and it's completely working fine without any issue, the problem seems to be with the WebGL

potent tendon
#

@sweet oriole @edgy mulch Just a heads up, I removed the floating function and tested again, the text's position is aligned properly. So the issue strongly I suspect is with the Time.time since WebGL takes a while to load and that could be causing the issue. Thanks to both you for all the help guys, means a lot to me 🥹

I'm gonna share this game project here in the respective channel in sometime, please do play the game, and share your feedback and any suggestions on it. I never worked on pure 2D game before and this is my first ever attempt without taking a proper 2D course as well so your feedback and suggestions can help me a lot🙏

In sometime, I will have the game shared here in the respective channel as said, please do visit once later, play the game and share your inputs 🥹 🙏

edgy mulch
#

🎊

potent tendon
# edgy mulch 🎊

I also have a couple of questions that I need answer for related to Game Dev, is it okay if I can DM you, please do let me know...🙏

edgy mulch
#

Oo alright go ahead

charred briar
#

Glad it's running though:)

edgy mulch
#

tbf it is a webgl bug

#

ill replicate it another day

thorn isle
#

Failed to download file Build/Build.data.br. 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 my unity webgl build is giving this error

edgy mulch
#

There's different ways to run it on a webserver

#

You could have it up on unity play or run it locally

sweet oriole
#

"Build And Run" button in Unity will spin up a temporary web server for you.

runic tiger
#

Does anyone know how to hide the last updated status on itchio?

charred briar
runic tiger
#

It was due a week ago but I figured no way they’ll check it that soon so I just made the project without uploading anything yet. But of course at the bottom of the page it now says last updated a few hours ago

charred briar
#

I'm pretty sure that's unchangably in there for game jam purposes. I don't think they would allow or want you to be able to change that

#

Or people would cheat at game jams which is itch.ios bread and butter

runic tiger
#

Makes a lot of sense

amber ginkgo
#

hi, a cold build for webgl for production, using brotli and LTO, is 1 hour normal for a 200MB game?

arctic rose
#

yes

charred briar
#

It also greatly depends on the project

astral wave
#

expecially if you have multiple quality settings and it needs to compile shaders for all of them.

deft fern
#

hello everyone

#

nice to meet you @everyone

#

I am a AI + Unity3D developer.

deft fern
#

Is there anyone here who has an idea to combine blockchain and the world of Game

wet grail
somber questBOT
#

dynoSuccess james03520 has been warned.

charred briar
spring crag
#

im a blockchain developer, currently learning unity. feel free to ask about any blockchain question 👍

magic wraith
spring crag
magic wraith
#

but nvm I think we ll go with an easier way

tight pier
#

Hello. Trying to make a web build so I can eventually upload this small game on itch.io. I have resolution settings set in game view, canvas, and player settings as you can see. For some reason, my web build is still way different than in my scene/game views. Any ideas?

tight pier
#

I was able to figure it out for everything but the bottom right bubble. I have it anchored bottom right. What seems to be happening is the default 0,0 x,y pos is being defaulted to whatever anchor point I set it on, and ignoring any values I put in x,y to make it actually appear on screen

#

deleting the old parent and creating a new one seemed to work even though the values didnt change, hm

storm tangle
#

Has anyone worked in Nvidia CloudXR?
If, please guide me to developing a VR app for oculus quest ?

honest swift
#

What should I do if the game in webgl on the iPhone does not work?

astral wave
untold field
#

How can we implement screen sharing in Unity WebGL

charred briar
#

I think fmetp or whatever it is supports webgl

honest swift
astral wave
# honest swift I set the webgl build settings to less than 300 MB and my game stopped running o...

that setting is not optimization. it sets limit after which it will crash. So you actually need to optimise game and use profiling to test memory usage.
https://docs.unity3d.com/Packages/com.unity.memoryprofiler@1.0/manual/index.html

Have in mind if you have a lot of textures or load textures in runtime, the correct compression format makes huge difference (up to 4x).
https://docs.unity3d.com/Manual/class-TextureImporterOverride.html

unreal abyss
#

does anyone know why chrome's webgl performance is SOOO bad compared to firefox? I haven't tested any other browsers except from chrome mobile which also has far better performance

cyan socket
#

Hello,
Does any one have idea about gamelift + mirror on webgl??
I have a server deployed on aws gamelift.
I developed a build which is working on desktop, but the same build not working on webgl platform

high patrol
#

well webgl you gotta use websockets for one

main shale
unreal abyss
sweet oriole
unreal abyss
edgy mulch
#

unity is not packaging my scriptable objects correctly

#

it messes up strings

#

2022.3.19f1

astral wave
#

Did you write that text in code editor or inside unity editor?
I would check files encoding options on your editor of choice. Make sure that files encoding is UTF-8 just in case. I had similar problem when file was changed on another editor and its dfault encoding was different than project.

edgy mulch
#

in the unity editor

#

it works fine for pc build but not for web build 😦

astral wave
# edgy mulch it works fine for pc build but not for web build 😦

Another idea is if you using textmesh and not legacy text elements: as you sure that your font have correct information for your text?
Reason: on editor, if font is not find for letter, it goes to system fallback font and displays it. On web there is no such system fallback logic. but in this situation characters should not be displayed at all.

Have you tried different Unity editor version? 2022.2.13 I am sure it works well ready data from scriptable objects.

edgy mulch
#

I'm using tmpro but The text in the rest of my game are working fine

edgy mulch
#

Another thing is that I'm using Master build mode if that affects anything

astral wave
edgy mulch
#

I tried both actl initially I copy pasted everything and saved it

#

And checked GitHub to see the changes reflecting

#

I also manually typed everything

#

Both doesn't work

#

In fact it seems like some of the texts are merged

astral wave
#

This might be a bit time consuming, but I think it would give you a lot of clarity. Create new project and try reproduce this behavior oh it. Make it as minimal as possible. If you are able to reproduce it, then you can calmly report as a bug. This will also help you to see where this data got corrupted. As if it a bug and you cant change version then you will need to create totally new workaround. Like creating script with all text you need and have it will some type of identifier for a workaround.

#

I also would debug.log all text into console on places you displaying it, so you could see if there is differences? maybe some parsing problems.

#

of course we can wait for someone else that had this problem. if they had

late lodge
#

Hi i have a problem with my webgl export.

i upload it on my personal website. The first time the game started well. but now it doesn't load at all. when i open the console i have all those errors

is there someone to help me ?

astral wave
# late lodge Hi i have a problem with my webgl export. i upload it on my personal website. ...

Well you in luck, as problem most likely not that big. The problem is you Index.html. When you build your webgl build it changes the names of files depending on directory you built. In this case FMVTest.data is not found. So when you change build folder, you need update index.hmtl as well to load correct files. Most likely if you will start page in incognito mode (aka remove cache) it should work.

#

OR

late lodge
astral wave
#

in your index html there a part where FMTTest.loader and other 3 files are loaded. you need to update that place or you need to make sure you always build in same folder.

#

that assuming you change all files

late lodge
edgy mulch
#

i will move this to another ch 😦

late lodge
astral wave
#

check Build folder if file names are correct. Then check FMCTest.loader.js if names are correct. and try opening in incognito window. as if you update the index html it does not mean it wont be loaded from cache on browser.

sinful badge
#

Hello everyone, does anyone here have a server hosted on AWS and the game running on itch.io?
I need help configuring the server to accept HTTPS requests.
I know I need the SSL certificate,
I obtained the certificate using a different domain, not the itch.io domain. How do I proceed?

high patrol
#

I think if you upload to itch, they are the ones hosting your game on their server. No need for a certificate unless you have an external server it has to talk to

sinful badge
#

Mixed Content: The page at '<URL>' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws:<URL>/socket.io/?
This request has been blocked; this endpoint must be available over WSS.

this is the error

high patrol
#

Ah, do you know where it's creating the websocket?

#

You'll have to change any ws:// urls to wss:// AND have a certificate associated with it. It can be a self signed cert for testing purposes. Otherwise you'll have to generate a csr for the server listening for the websocket connections and get it signed and then attach it to that server

sinful badge
arctic rose
#

Browsers won't accept self-signed certs

high patrol
#

It depends on the environment, you very well might be forced to actually get a signed cert rather than a self signed cert, depending on the environment. If you are hosting a "front end" on itch and having it talk to YOUR backend server over a websocket, I definitely would not roll a self signed cert.

#

Namecheap has them for $6/year

arctic rose
#

Let's Encrypt certs are free

sinful badge
#

Ok, thank you guys

#

I will study it

arctic rose
#

AWS-issued certificates from Certificate Manager might also be free, not sure about that

high patrol
#

certs can be a pain, good luck!

sinful badge
#

but this certificate I obtained with my domain, playforkant.com, but the domain is trying to acess my backend server is itch.io

I actually did not understand well yet

arctic rose
#

You don't need a certificate for itch.io

sinful badge
high patrol
#

your domain should point to your AWS instance, and your backend certificate should be tied to that domain/subdomain running the server on playforkant.com

#

you'll have to reupload your itch webgl build after changing the ws:// call to wss://XYZsubdomain.playforkant.com

calm stream
#

Hey there mates! I used the SimpleWebServer to test a WebGL build locally on localhost:8017, how can I stop the server from running?

solar hound
#

how to faster load the WebGL build, it sometime takes too much time to load with same build

vivid lantern
#

Has anyone worked with discord API in webgl?

#

It needs both dlls but absolutely hates that they have the same name

high patrol
calm stream
astral wave
#

the first one takes foreever. others takes less. Also it depends on how many shaders it needs to compile and etc

astral wave
astral wave
vivid lantern
#

Renaming or deleting them breaks it

#

And building it for windows let's you keep both

astral wave
vivid lantern
#

Yes and no

#

It works on windows and breaks when building for webgl

#

When I build it for webgl it throws an error - 2 DLLs with the same name

#

If I remove any of them build is successful but it throws an error (referenced DLL is missing)

#

I even tried renaming the dlls

dim pollen
#

Hello everyone, I'm a total beginner in Unity, but I saw some things on YT and wanted to confirm the feasability of an idea. I want to create an augmented reality app that won't need to be downloaded (so web hosted), and that coulb be used with iOS and android. The thing is, I've heard that since I'm developping in a windows environment, I couldn't make it work for iPhone users. Is it true or is there a solution ?

arctic rose
#

Only true for native apps, not web apps. Thankfully Apple hasn't found a way to restrict iPhones to browsing only websites that were made with Macs

dim pollen
astral wave
# dim pollen That's good news ! Now, I browed Unity tutos to learn how to create the said app...

Mostly you can follow native app tutorials. There are some things you cannot do and some things are done differently on webgl. Main difference how you load files (I would assume you will not have all 3D objects in build and will need to download them). Aslo webgl dont support VFX at all. If you use external plugins, you cannot use c# dlls and etc. Memory manangment needs to be spot on, or you will have crashes on iOS (tarrget about 350mb RAM for older iOS). No compute shaders. No HDRP. Accessing devices can be more complicated (like camera or gyroscope).

https://docs.unity3d.com/Manual/webgl-graphics.html
https://docs.unity3d.com/Manual/webgl-develop.html

But I fully see you creating that kind of app on webgl. Tho have in mind Unity have quite high overhhead, so project size and performance won't be too good. Minimum 4 times worse than native app.

dim pollen
astral wave
dim pollen
#

I understand ^^ thank you very much !

charred briar
#

But usually when I'm doing webxr of any kind, I'm not using Unity. You usually use aframe or something else to do that.

calm stream
#

Hello pretty people, would anyone know why the shadow works fine on edito playmode and is cutted off on webgl build on browser?

charred briar
calm stream
edgy mulch
#

why are web builds much smaller than desktop builds? my current desktop build is 1.7gb but the web build is only 300mb

#

compression isnt enabled

astral wave
edgy mulch
#

most of my space is textures

#

some of the maps are almost empty and are very compressable

#

but i didnt enable compresison

astral wave
#

by compression enabled what do you mean? there are like 3 compression options. YO utalking about brotli/gzip? are you talking about textures compression options?
what does your build report says?
Does your WebGL and PC builds have all quality settings enabled?

#

or you talking about default setup on webgl player options;

vestal siren
#

Can someone help me how to use opencv in webgl build for free in unity

rotund hemlock
#

is it possible to use webgl for submitting form online? I have html form and want to require user to beat game/ win simple game for form to submit

charred briar
charred briar
astral wave
rotund hemlock
#

thank

#

to all

#

that look like just what i needed

rapid oasis
#

Hello, have a bit of a wierd question, currenlty have a game thats working all fine on web no issues. but for testing purposes we tried to run the game on android google chrome and everything works fine apart from the saving to clipboard.

this is the c# func

    [DllImport("__Internal")]
    private static extern void CopyToClipboardImpl(string text);
    public void OnCopyAddress()
    {
        var textToCopy = DojoEntitiesStorage.currentAccount.Address.Hex();
#if UNITY_WEBGL && !UNITY_EDITOR
        CopyToClipboardImpl(textToCopy);
#else
        GUIUtility.systemCopyBuffer = textToCopy;
#endif
        Debug.Log($"Copied: {textToCopy}");
    }

this is the js end

  CopyToClipboardImpl: function(textPointer) {
        var text = UTF8ToString(textPointer);
        navigator.clipboard.writeText(text).then(function() {
        console.log('Async: Copying to clipboard was successful!');
        }, function(err) {
        console.error('Async: Could not copy text: ', err);
        });
    },

i am guessing it has something to do with permissions but i am not too sure.

Edit: so it turns out it actually works fine, but to make it work i would first have to click on a textfield input, exit such textfield input and then the copy code works fine... still this is not really the meant behaviour

lilac rose
#

I am still having issues with my WebGL going to 90% when I try to play

lilac rose
#

I was told by classmate that they are able to play my game, but its nor loading on my end

solar hound
#

Hi, I have a WebGL build, and I want to detect if a user opens the other Tab through the script, Is it possible to do?

charred briar
# solar hound Hi, I have a WebGL build, and I want to detect if a user opens the other Tab thr...

You can check if they lost focus? You won't know for sure if its another tab though. If it is from your own page that you want to monitor, you can do it web side, and then feed it to Unity:
https://stackoverflow.com/questions/54040065/how-to-detect-new-tab-is-opened-from-current-page

solar hound
#

@charred briar I have already implemented the Lost Focus but it is also called when the other dialog appears or just leaves the app in the background. No, the other tab may be anything like the new tab or other they are not from my page.

charred briar
solar hound
#

@charred briar yes, I think the same way. thanks for answering!

rustic pewter
#

I'm running into an odd issue and wanted to see if anyone else has experienced this:
Running a WebGL build on a specific device (Galaxy Tab A) in the past worked without issue.
Now however it just shows a black screen. If I enable the splash screen, it works fine.
If I press the full screen button it will show a black screen.

This build works fine on other android devices in the browser.
This has been tested with Unity 6, 2023, 2022 on an empty project.

#

This also only happens when building with URP, built-in works fine.

charred briar
rustic pewter
#

Hey, thanks for the response, it definitely does seem related to the issue I am having.
In my test project, I do have all post processing and other rendering features turned off.
I took a look at the link and tried setting the texture compression to ASTC, however it did not seem to make a difference 😦

#

Ok, this is odd, I set it to gamma color space and it worked 🤔

charred briar
#

I know linear lighting doesn't work on all platforms so that makes sense

orchid bridge
#

does anyone know how to fix ERROR:root:emcc: cannot find binaryen js libraries (tried: ('/usr/bin', '/usr/share/binaryen'))?
Unity 2019.4.40f1, arch linux-lts

solved: copied unity's version of binaryen entirely into /usr/bin

#

I have the binaryen package installed

orchid bridge
#

well I got past that.. but what the heck does this mean?

#

It seems to be happening when gzipped file contents are expanded in the virtual fs

orchid bridge
#

It seems to happen when it tries to load music_assets_.bundle, which is 455mb, and probably above what the virtual "memoryFS" can handle

#

firefox has a completely different issue, where it will just OOM instead :c
about:performance says it is using ~5gb when oom happens, which seems insane because the entire game is 1.4gb

orchid bridge
#

Ah yes, Exception: Files.

random talon
#

I integrated a WebGL game in a mobile app through a webview. The issue is that on some devices the unity part boots up but I get a black screen on the first seconds before going back to normal. Has somebody any idea why this could happen?

orchid bridge
#

guys, can webgl work on all mobile devices by registering touches as inputs?

For example, Lets say we have virtual joystick on screen for movement that would be used on android and IOS devices in general, but could webgl do it the same if it is run on mobile? 👀

orchid bridge
#

So webGL and await async is not working?

astral wave
# orchid bridge So webGL and await async is not working?

async and await does work. Tasks and threading does not. I strongly suggest using UniTask plugin if you want to use tasks and etc. Have in mind it will not be multithreaded, it will just fake it, but at least code transition is easy.

astral wave
orchid bridge
#

btw if someone knows how to update old code so that I dont get "runtime.dynCall is not a function" errors when I am using webassembly 2023 option in unity?

astral wave
orchid bridge
versed cargo
#

Hello everyone,

I recently found a bug in my application related to the screenshot capture system. Has anyone else encountered this issue before?

My app is developed with WebGL and the WebGPU option enabled in Unity(2023.3.0a14)

Here is my method:
`IEnumerator TakeScreenShot()
{
if (!VirtualVisitManager.Instance.player.activeSelf)
{
UIManager.Instance.HUDState(false);
}

yield return new WaitForEndOfFrame();

// Log to ensure we are capturing at the right time
Debug.Log("Attempting to capture screenshot...");

Texture2D tex = ScreenCapture.CaptureScreenshotAsTexture();


if (tex == null)
{
    Debug.LogError("Failed to capture screenshot texture.");
}
else
{
    byte[] bytes = tex.EncodeToPNG();
    string stringifiedPNG = Convert.ToBase64String(bytes);
    this.Emit("screenShot", stringifiedPNG);
    Destroy(tex);
}

if (!VirtualVisitManager.Instance.player.activeSelf)
{
    UIManager.Instance.HUDState(true);
}

}`
Here is the error i have :

I havn't found a lot of topic about that on web maybe it happened to one of you ?
Maybe WebGPU do not support WaitForEndOfFrame anymore ?

trail shoal
#

@cold frost um why did i get banned i was at shopping and i just got home like 10 min ago and my brother was at home but sometime i let him play roblox on my pc.. did he got on my discord? but i saw on your DM so that wasn't me and i did told him not to get on my pc.. so can i get a chance to be unbanned or ban appeal?

trail shoal
#

but i wish it has a warning instead ban

charred briar
trail shoal
#

well im talking to uv of his discord name Learn unity

trail shoal
random talon
#

Trying Unity 6 preview, is WebGPU not yet available?

sweet oriole
# random talon Trying Unity 6 preview, is WebGPU not yet available?

    Navigate to an existing Unity project and open the ProjectSettings.asset file (located at <project folder>/ProjectSettings/ProjectSettings.asset) using a text editor.
    Search for a setting titled “webGLEnableWebGPU”:
    If found, change the line to “webGLEnableWebGPU: 1”.
    If not found, add a line “webGLEnableWebGPU: 1”. (This line can be added anywhere in the file, preferably next to other web-related settings.
    Open the project in the Unity Editor, using the latest 2023.3 release.

WebGPU should now be available in Graphics APIs. WebGPU support is experimental.

weary viper
#

These imports worked in Unity 2019 but no longer work in 2022 which i had to upgrade to:

[DllImport("__Internal")]
private static extern void ShowMessage(string str);

[DllImport("__Internal")]
private static extern void ProgramStart();

[DllImport("__Internal")]
private static extern void ProgramEnd();

[DllImport("__Internal")]
private static extern string GetWCFURL();

[DllImport("__Internal")]
private static extern string GetUploadURL();

Unfortunately i cannot provide any more context or in information than that as it's a project i'm jumping on and there's no individual or documentation to consult.

Does any of that look even vageuly familiar to anyone?

#

This is in a script called JSBridge for some kinda javascript stuff apparently

#

So thier referencing some internal functions in unity which i have no idea how to check to see what has changed or been removed between versions

weary viper
#

Narrowed it down tom these two:

[DllImport("__Internal")]
private static extern string GetWCFURL();

[DllImport("__Internal")]
private static extern string GetUploadURL();

ShowMessage, ProgramStart and ProgramEnd work

astral wave
#

Well there isn't anything we can help with this kind of information. At least error message would help. As it can be anything there inside. it could be Runtime.dyncall problem, which were changed in new unity versions. It could be some kind of depreciated code and using Pointer_stringify instead UTF8ToString (tho this still should work). Or it could be any changes with Emscripten version changes. The most generic solution, if this is third party plugins, check maybe update for them already exists.

weary viper
# astral wave Well there isn't anything we can help with this kind of information. At least er...

Thanks so much for the feedback @astral wave, i can provide a bit more feedback now after debugging last night and it looks like all those extern calls are referencing a .jslib file in the project and this is what the contents of that file looks like:

mergeInto(LibraryManager.library, {

ShowMessage: function(message){
    window.alert(Pointer_stringify(message));
},


ProgramStart: function(){
    sessionStorage.setItem("UnityState","Started");
    
},


ProgramEnd: function(){
    sessionStorage.setItem("UnityState","Finished");
    
},

GetWCFURL: function() {
var returnStr = sessionStorage.getItem("WCFURL");
if (!returnStr) {
console.error("GetWCFURL: No WCFURL found in sessionStorage.");
returnStr = ""; // Handle the case where returnStr is null
}
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
return buffer;
},

GetUploadURL: function() {
var returnStr = sessionStorage.getItem("UploadURL");
if (!returnStr) {
console.error("GetUploadURL: No UploadURL found in sessionStorage.");
returnStr = ""; // Handle the case where returnStr is null
}
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
return buffer;
},

});

So the GetWCFURL and GetUploadURL functions there at the bottom return values in Unity 2019, but null in Unity 2022

random talon
#

I've made a script to enstablish a websocket connection with a remote service, it works perfectly on editor but on webgl it crashes.
Any idea on why and how to fix it?

#

Is this true?

"WebSocket-sharp does not export (in a working condition) to WebGL.
You need a JS library to integrate the browser WebSocket API for Unity."

astral wave
#

WebGL does not support c# or other languages for websockets or networking. You are stuck with JS solutions. well technicly you can use c++ somehow, but in general JS is only way

random talon
high patrol
#

NativeWebSocket is definitely the best way to do it. Still uses unmanaged JS under the hood, but it's not too bad

orchid bridge
#

Why is there no exact implementation of OnApplicationQuit in 2024 ._.? Even the Unity documentation itself didnt mention about how to integrate OnApplicationQuit, why am i supposed to use SendMessage which is really similiar to 90's web solution

sweet oriole
orchid bridge
#

I would like to be able to implement that method for every MonoBehaviour instead of restricting the event by SendMessage(object, method, arg). I understand there are workarounds for integrating OnApplicationQuit() and i believe it is the simplest solution but i suppose it should have been a part of Unity already somehow and just yelled... Therefore, the same issue goes to OnApplicationFocus/OnApplicationPause because of every web browser's different systems even some share the same base 'Chromium'

sweet oriole
#

Not sure if there is a real workaround. Seems like platforms aren't keen on apps doing bunch of stuff when user wants to close them.

#

What are you trying to do?

orchid bridge
#

I was going to use these methods for cleanup of a MonoBehaviour(dependency chain). But now, i will be going to create a singleton(depends on platform i build) that holds the IsPaused, IsGoingToQuit, IsQuitting and IsFocused.

#

Personally, i hate singletons they are hard to manage sometimes if it didnt planned correctly...

orchid bridge
#

I am uploading my game on Unity Play, but the screen stops here. It shows no errors and does not proceed further. If anyone knows why this happens, Please help me.

sweet oriole
dry locust
#

Hi All

I'm trying to get webGL working
I am very close, my game runs, only issue is my buildings dont load 😦
I think its a texture format issue, I see GL_INVALID_OPERATION: Mismatch between texture format and sampler type errors in the console
I am manually creating some textures in the editor as TextureFormat.RGBA32 I'm trying other formats but no idea what to use

#

These files are put into a addressable bundle... maybe thats an issue too?

dry locust
#

This is what im seeing on WebGL with RGBA32 and RGB24
The blocks seem to be receiving shadows but no color is loaded 😦

dry locust
#

Turns out it's the shaders
I have a dual project addressable setup and for some reason only in webgl the shaders built in my content project don't work
I've copied them into my main project and replace the loaded ones and it seems better

visual siren
#

Hi there people. I'm trying to do a test WebGPU build from the new unity 6. When I hit build and play it works, however I triend to set up nginx so that other people on the local network can test and there I get the following error

#
    at ShaderLab::Pass::ApplyPass(unsigned int, ShaderPropertySheet const*, DynamicBranchState*, ShaderPassContext&, keywords::LocalKeywordState const&, Shader const*, int, int, ShaderLab::GrabPasses const*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*, ShaderLab::Pass const*, ShaderLab::Pass const*) (http://192.168.0.55/test/Build/web.wasm)
    at ApplyMaterialPass(SharedMaterialData const&, ShaderPassContext&, Shader const*, ShaderLab::Pass*, int, int, ShaderLab::GrabPasses const*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*, ShaderLab::Pass const*, ShaderLab::Pass const*) (http://192.168.0.55/test/Build/web.wasm)
    at Material::SetPassSlowWithShader(Shader*, int, ShaderPassContext&, int) (http://192.168.0.55/test/Build/web.wasm)
    at Material::SetPassSlow(int, ShaderPassContext&, int) (http://192.168.0.55/test/Build/web.wasm)
    at DrawQuad(RectT<float> const&, float, Texture*, ColorRGBAf const&, RectT<float> const&) (http://192.168.0.55/test/Build/web.wasm)
    at DrawSplashScreen(bool) (http://192.168.0.55/test/Build/web.wasm)
    at MainLoop() (http://192.168.0.55/test/Build/web.wasm)
    at dynCall_v (web.wasm:0x36d187f)
    at web.framework.js:897:22
    at web.framework.js:1835:24
    at _JS_CallAsLongAsNoExceptionsSeen (web.framework.js:1835:39)
    at UpdateUnityFrame() (http://192.168.0.55/test/Build/web.wasm)
    at dynCall_v (web.wasm:0x36d187f)
    at web.framework.js:897:22
    at browserIterationFunc (web.framework.js:6146:51)
    at callUserCallback (web.framework.js:5423:9)
    at Object.runIter (web.framework.js:5479:11)
    at Browser_mainLoop_runner (web.framework.js:6117:26)```
#

obviously since the build and run option works something is wrong with my nginx conf but I did copy the conf from the documentation.

astral wave
#

did you config nxginx .wasm or what ever is needed for webgpu correctly? And do you have enable fallback feature enabled on build settings? It could be that it does not have correct config on ngxing and then tries to load fallback build, which does not work unless it is webgpu

serene jackal
#

Does anyone know if you can run async/await/tasks methods in a webgl build?

astral wave
serene jackal
amber ginkgo
#

hey. i hosted a unity webgl server with python -m http.server and it runs fine on all platforms except for iOS. any idea how I can fix it?
the error invisible, the page simply goes to unknown error screen after the initial loading is finished (assets are downloaded)

astral wave
# amber ginkgo hey. i hosted a unity webgl server with `python -m http.server` and it runs fine...

Welcome to iOS. The land of wonders and secrets. What you need to do is to check errors on console. You can do that by opening separate tab "chrome://inspect" (if used chrome, different browsers have different ways to do it) then turning on logs tracking. Then open your app in another tab and check what the logs says. Or you will need to connect device to your Mac device and get logs from there. As no error can mean anything.

HOWEVER, depending on your device, the most common problem is memory usage. As unity webgl have very strict memory usage on iOS devices, especially a bit older. If you application uses more than 300-350 mb RAM, it is totally possible that it will just crash on iOS devices because you run out of that memory limit. Yes, it does not matter how much memory your device have, it just hidden limitations that you need to follow. (surprisingly PlayCanvas don't have that strict limitations, so IDK from where it comes, but they just there). In this case you would want to connect Unity profiler to your project to see memory usage and more precise logs for that. Also have in mind, that memory usage on iOS can be up to 4 times bigger than other devices, depending on what textures compression you are using (https://docs.unity3d.com/Manual/class-TextureImporterOverride.html more about it here).

Or it could be easily some kind of rendering feature that iOS just dont support. But that is way harder to find, and connecting your profiler is only way to find it I think. Or make multiple builds, like with only one scene or etc, to make is as small a possible and keep adding features and quality settings until you find the culprit,

In general i dont really believe that is problem with your web server if other devices are running fine on it.

amber ginkgo
# astral wave Welcome to iOS. The land of wonders and secrets. What you need to do is to check...

Thank you for your thorough information! The game did start throwing error after I added a new set of UIs, so the memory limitation issue seems most likely. I also remember seeing some alloc in an error message once or twice (sometimes it shows a web assembly error before crashing). I tried narrowing down the issue by using various git tools, but I totally disregarded the new UI elements since I thought it unlikely that a series of textures would cause an unknown error crash, but that's probably the error.

Thanks again!

serene jackal
# astral wave you can use async and await (with some limitaions). Tasks are impossible in webg...

hey sorry for the ping but i was messing around looking through stuff and saw in the ProjectSettings.asset theres a webGLThreadsSupport that can be set to 1, wanted to ask if this is worth messing with?

also i forgot to mention that all my async operations are not in game, its doing stuff in the lobby like fetching lobbies, joining a room, etc, and i did test it as a Task in a browser and it seemed to execute fine, dont know if its because its just doing such little or what tho

sweet oriole
# serene jackal hey sorry for the ping but i was messing around looking through stuff and saw in...

Afaik webGLThreadsSupport only affects engine threads, so native and (I believe) Job threads. My understanding is that C# threading support is not offered at all until they have a way to gracefully fallback to no threading support.

Tasks might work until some API invokes something relying on threads (it's not always obvious), in which case it might just silently fail. I would use UniTask or other equivalent solution to use Tasks safely.

serene jackal
#

ok i can try out UniTask, is it like a well known thing and trusted to work?

sweet oriole
serene jackal
#

Awesome

#

Thanks for the help!

astral wave
# serene jackal hey sorry for the ping but i was messing around looking through stuff and saw in...

From what I understood that webGLThreadsSupport enables threading only for C/C++ code and also browser needs to support that. Multithreading C# code is not yet available. (https://docs.unity3d.com/ScriptReference/PlayerSettings.WebGL-threadsSupport.html)

I used UniTask on webgl project, it is really well made. Maybe you wont win performance, but it is way more convenient to use. Also it have similar grammar as unity tasks, so it would be easy to transfer if WebGL EVER would start supporting C# threading. So no downsides pretty much.

serene jackal
serene jackal
#

that was really easy to implement, thanks for all the help guys @astral wave @sweet oriole

solar hound
#

When i run my unity project in web i got this error ```UnityLoader.js:1

   Failed to load resource: the server responded with a status of 404 (Not Found)```
astral wave
#
  1. Make sure the files have correct names. When you build webgl and change build folder, names changes accordingly. so if you keep old index.html or UnityLoader.js it will fail to find assets or load old ones if you have them
solar hound
#

@astral wave Hi, I have successfully uploaded my Webgl to the server, I transferred my Unity WebGL build from Unity 2019 to 2022, and when I uploaded it to the server this new version of the build took of time to load, previously On Unity 2019 it loaded so fast. here are my Webgl settings.

#

and also get this warning when start my webgl app

astral wave
cosmic hamlet
#

anyone else having general audio issues with web builds on unity 6? e.g. AudioSource.time and AudioSource.timeSamples are desynced, looping audio suffers a slight silent period, and AudioSource.PlayScheduled() plays stuff immediately instead of at the scheduled time.
this is my first message here so i'm not sure this is the right spot for this stuff, please lmk if its not

solar hound
#

Hi, I transferred my project from Unity 2019 to 2021 I built for WebGL, and in the 2019 version there is a UnityLoader.js file created inside the build folder but in 2021 there is no such file UnityLoader.js which necessary for upload my build to server, help me

#

here is a difference of the build folder of two unity versions

astral wave
#

most likely what you need is Proslat.loader.js. In ne Unity it is beeing renamed depending on your build folder. So I assume you build it in Proslat folder. Or you can just update your index.html with new template for loading you project instead of using UnityLoader.js. Also why not ugrading to unity 2022 or 2023? the later the version the more webgl improvelements there is, from more memory control to... well.. there were more stuff there I am sure about it

solar hound
#

Update to 2022 and make some changes in index file now its works fine, Thanks @astral wave

halcyon aspen
#

Hi, I use react-unity-webgl, and have event that will send devicePixelRatio to adjust performance, but when i update it it don't change resolution.

const [devicePixelRatio, setDevicePixelRatio] = useState(
    window.devicePixelRatio
  );
useEffect(() => {
    addEventListener("SetDPR", (dpr: any) => {
      setDevicePixelRatio(dpr);
    });
    return () => {
      removeEventListener("SetDPR", (dpr: any) => {
        setDevicePixelRatio(dpr);
      });
    };
  }, [addEventListener, removeEventListener, setDevicePixelRatio]);

return( <Unity
            id="unity-canvas"
            tabIndex={1}
            unityProvider={unityProvider}
            className="h-full w-full outline-none"
            style={{
              visibility: isLoaded ? "visible" : "hidden",
            }}
            devicePixelRatio={devicePixelRatio}
          />)

If I use matchWebGLToCanvasSize={false} and manually set canvas width and height it works but image is shifted and buttons in game are not clickable

const canvas = canvasRef.current;
    if (canvas) {
      var width = window.innerWidth;
      var height = window.innerHeight;
      canvas.width = width * devicePixelRatio;
      canvas.height = height * devicePixelRatio;
    }
spare onyx
#

I'm trying to reduce my build size and I'm wondering if anyone has insights into what this Unknown stuff is?

astral wave
spare onyx
#

Checking log files does not add any more info to this unfortuatly

amber ginkgo
#

also, in the logs look for the exact words "Uncompressed usage by category (Percentages based on user generated assets only):" and check the sorted list out

#

will see something like this

-------------------------------------------------------------------------------
Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               2.8 mb     94.2% 
Meshes                 0.0 kb     0.0% 
Animations             0.0 kb     0.0% 
Sounds                 0.0 kb     0.0% 
Shaders                6.8 kb     0.2% 
Other Assets           1.3 kb     0.0% 
Levels                 0.0 kb     0.0% 
Scripts                137.5 kb     4.5% 
Included DLLs          0.0 kb     0.0% 
File headers           29.3 kb     1.0% 
Total User Assets      3.0 mb     100.0% 
Complete build size    68.9 mb
Used Assets and files from the Resources folder, sorted by uncompressed size:
 2.7 mb     3.9% Built-in Texture2D: Splash Screen Unity Logo
 128.2 kb     0.2% Built-in Cubemap: 
 7.4 kb     0.0% Resources/unity_builtin_extra
 0.4 kb     0.0% Built-in Sprite: 
 0.2 kb     0.0% Packages/com.unity.test-framework/UnityEngine.TestRunner/NUnitExtensions/Runner/RestoreTestContextAfterDomainReload.cs
 0.2 kb     0.0% Packages/com.unity.visualscripting/Runtime/VisualScripting.Core/Listeners/UI/UnityOnScrollbarValueChangedMessageListener.cs
 0.2 kb     0.0% Packages/com.unity.visualscripting/Runtime/VisualScripting.Core/Listeners/UI/UnityOnScrollRectValueChangedMessageListener.cs
 0.2 kb     0.0% Packages/com.unity.visualscripting/Runtime/VisualScripting.Core/Listeners/UI/UnityOnInputFieldValueChangedMessageListener.cs
...
main plover
#

Anyone got recommended settings/workflow for publishing webgl builds on itch.io? Specifically confused about the resolution and what to set on itch.io, seems a bit weird.

I kind of found someone setting 960x540 in unity and on itch game page settings the size to 960x590 so the fullscreen button is visible which seems to work but is it the correct way?

amber ginkgo
#

hi. has anyone had experience deploying a build to apache2 server with the correct .htaccess config?
I followed the official docs and configured the following

# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
<IfModule mod_mime.c>

# The following lines are required for builds without decompression fallback, compressed with gzip
#RemoveType .gz
#AddEncoding gzip .gz
#AddType application/gzip .data.gz # The correct MIME type here would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it's preferable to use MIME Type application/gzip instead.
#AddType application/wasm .wasm.gz
#AddType application/javascript .js.gz
#AddType application/octet-stream .symbols.json.gz

# The following lines are required for builds without decompression fallback, compressed with Brotli
#RemoveType .br
#RemoveLanguage .br
#AddEncoding br .br
#AddType application/octet-stream .data.br
#AddType application/wasm .wasm.br
#AddType application/javascript .js.br
#AddType application/octet-stream .symbols.json.br

# The following line improves loading performance for uncompressed builds
#AddType application/wasm .wasm

# Uncomment the following line to improve loading performance for gzip-compressed builds with decompression fallback
# AddEncoding gzip .unityweb

# Uncomment the following line to improve loading performance for brotli-compressed builds with decompression fallback
AddEncoding br .unityweb

</IfModule>

which compiles to just

AddEncoding br .unityweb

(as you see, i commented out everything that does not correspond to my build setup, which is brotli with fallback)
but I still get the error message

"You can reduce startup time if you configure your web server to add "Content-Encoding: br" response header when serving "Build/webgl.wasm.unityweb" file."

#

(I have placed the .htaccess to the /Build folder relative to index.html file

#

(also worth noting that apache is indeed reading those configs, because I accidentally commented a line with ; instead of # and it gave me syntax error:

[DATE] [core:alert] [pid PID:tid TID] [client PUBLIC_IP:0] /home/admin/web/DNS/public_html/Build/.htaccess: Invalid command ';', perhaps misspelled or defined by a module not included in the server configuration, referer: https://DNS/
``` *(uppercase words are censored)*)
#

in case relevant, here's the config code related to serving the website in the first place

...
    <Directory /home/admin/web/DNS/public_html>
        AllowOverride All
        Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
    </Directory>
...

(uppercase wors are censored)

#

well I'll be damned. I re-tested several times and it finally worked 😅 maybe apache2 was using cache? (i know i deleted the website's cache on browser through edge://settings/sitesettings)

real bone
#

Newb question. What is your go-to method for profiling Unity heap usage in the browser. Specifically the Unity heap allocated by WASM.

#

I'm finding it difficult to find resources specifically to view the WASM heap and chrome doesn't seem to display WASM heap usage in the memory profiler.

astral wave
# real bone I'm finding it difficult to find resources specifically to view the WASM heap an...

https://docs.unity3d.com/Packages/com.unity.memoryprofiler@1.1/manual/index.html
I would mark autoconnect profiler when you click build and run. Then open memory profiler, it gives quite accurate data about a lot of things.

Browser will not give you exact values, as it is not JavaScript and quite closed enviroment to get data from. And different browsers handle that differently. Some even limits memory differently;

forest pilot
#

does LevelPlay/Unity Ads work for webGL builds at all? Is there any solution for in game ads in WebGL?

sweet oriole
# forest pilot does LevelPlay/Unity Ads work for webGL builds at all? Is there any solution for...

WebGL builds are websites, so you can just use regular website monetization methods. Some web game portals want you to do ads through their SDK, but the ads are still most likely ads from big web ad networks like AdSense.
Having the game up on your own website with ads allows you to use the same setup across multiple web game portals (there are hundreds) through iframes. You also don't need to worry about updating builds across multiple websites or maintain multiple SDK integrations. Some of the big web game portals really want you to use their SDK since they can take a cut and control the experience. How much say you end up having depends on how much those portals want your game(s) on their site.

clear sierra
#

hey does anyone have any clue why my webgl addons arent installing? it just stays like this for hours with no sign of progression

sweet oriole
somber questBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

craggy quarry
#

I have a question, if publish a simple unity game with webGL. Can I add a c# file which help user to play only 1hr in 24hr time. I heard about concepts session or cookies to take record which device accessing service.

arctic rose
#

You can store the time the player has played to PlayerPrefs. Note that there is no system that would actually stop the player from clearing browser data and playing more apart from using user accounts, and even then you can't prevent them creating multiple accounts (other than in very restricted situations)

orchid bridge
astral wave
orchid bridge
#

I've been waiting for WebGPU to be fully ready before I moved to the next version.

astral wave
orchid bridge
#

As I know WebGPU will certainly be a game change if they manage to add support for the new resident drawer for example.

astral wave
#

and I doubt you will ignore all iOS and Mac users.

orchid bridge
#

Ops I was confusing 2023 with Unity 6 😅

orchid bridge
narrow tusk
#

Hello

orchid bridge
#

My build is 40MB right now but if I can split my scene and offload the audio assets into the second scene, it cuts my initial build size by 50% which is ideal for WebGL game. Although hmmm I wonder if 40MB is really that noticeable of difference to end-users these days with such fast internet speeds we have

narrow tusk
#

So I need some help with unity, where do I go?

charred briar
astral wave
orchid bridge
orchid bridge
amber ginkgo
#

ideally you'd go as low as 4MB (with Project Tiny and DOTS you can go even lower I believe, but I haven't seen proof of it yet)

#

a lot of the things will be stripped out when you use the high stripping settings. And all assets should be asset bundles; no exceptions except for the initial loading assets if you want

#

a quick way to reduce tons of build size is to remove big 2D arts (any texture, not just 2DTexture) from the build and have the player download them instead. this is a pretty quick fix, as it doesn't require any change anywhere in your system except for your image displayers

*so instead of assigning Sprites manually, you'd assign some custom type, say, GenericSprite instead, which accepts some asynchronous operation in which it'll decide whether to load the asset from local database or from remote. so like
background.Sprite = myManifest.rareCardBackground) codes would be similar to something like
myManifst.rareCardBackground.GetAsync(sprite => background.Sprite = sprite); *

astral wave
# amber ginkgo its not...

Yea project tiny and other super stripping projects can become small, but you strip pretty much everything even some features, and in reality it is rare project that will spend so much time doing that. So 40 mb is great, I do not take my words back. I was able to strip it to 15mb, and then load all other 150 mb little by little when needed. While doing same project in playcanvas with all the same assets total size of everything is 40 mb. where 5mb is initial load almost without any optimisations. So 40mb for unity webgl is great, and it is hard to make it lower, and it should be celebrated.

orchid bridge
# amber ginkgo its not...

I would ideally love to go smaller than 40MB... and I can if I can fix this stupid Audio issue not loading in Asset Bundles.

I do believe initial load time of a game is critical to help ensure a low bounce rate.

Although, I'd argue that this may not be an issue if players are actually excited about the game they are going to play. So yes, they will wait an extra 10 seconds or more for it.

I say this based on what i've seen with a popular .io game built with Unity known as ZombsRoyale for example. This game is 2D and is 100MB if not more at initial load, and it's one of the most successful .io / Unity WebGL games to date. The developer earned millions $$ off this game.

So yea... I'd say that it really all depends on the game. ZombsRoyale already had a massive following due to the success of Zomb.io, so in this case it was a no brainer for players... they'll wait for that 100MB download in the browser 😄

For other games developed by unknown / new developers and pushing a large build size like this... i'd argue the marketing of said game is what will help determine if players will be willing to stick around for it to load or not.

amber ginkgo
charred briar
#

If you want to get the smallest possible packages sizes for web, I'd recommend looking outside of unity entirely. It's great for cross platform though, and does an excellent job of webgl support. But it's always been a bit of a hack job.

By It's nature, web auto compresses at the server level and feeds you content as you need it. In theory you should never need to see a loading bar or directly manage compression and upload gzipped binaries.

But you trade size, control and loading for a more robust and complete engine. There are a ton of other webgl engines worth checking out though when trying to stay small. Also, last I checked project tiny was killed off paused in favour's of building out things like AI tools on a subscription

orchid bridge
# charred briar If you want to get the smallest possible packages sizes for web, I'd recommend l...

Yea I would have totally gone with Playcanvas if I wasn't already a long time Unity user. I'm just comfortable with it, and well the productivity is much higher at least for me going with Unity based on the type of games I like to make. I'm a web developer by day and love all things JS, but JS engines are still way behind Unity. So ya I prefer the complete engine, and all the resources that come with Unity in comparions to other solutions. I'm not entirely worried about keeping my build size extremely small.

amber ginkgo
#

Complexity plays the major part in this choice. The hamster game would probably lose a lot of users if it used Unity and required webgl and a seconds long initial loading

charred briar
#

Don't get me wrong, I use Unity for the web all the time, and we do some amazing stuff with it. It's just that if package size is really cruicial, there are way better tools for most small-use applications.

#

If size isn't a major concern though, it's going to be hard to beat Unity for what Unity can do with the web though 🙂

#

And having singular code bases is a great thing, as long as you don't mind vendor lock.

solar hound
#

I uploaded my WebGL build to the server, and it works on Firefox but on Chrome something is weird with the text there are squares instead of texts. see images with the same URL, left Firefox and right Chrome. Could you help me to resolve this issue? also works when using an incognito tab in Chrome that suggests something about cache issue.

astral wave
solar hound
#

works when hard reload, but i don't understand why this build use cache when i disabled the Data caching in player settings.

solar hound
#

@astral wave

astral wave
# solar hound <@821626071853694987>

Wwhat I can say, webgl is magical beasts. As data caching also depends on browser settings, and you not always can control it. While on development state, it is really not important to fix this, but later in production you could just change files names to have version numbers to it, that way it will always load new files ignoring cache.

#

You are lucky you dont need Asian fonts, then webgl becomes even more magical 😉

#

Also you didnt answre about which text asset you are using. Legacy wont have this problem, as it will use fallback browser fonts on problem like that. but it is way less performant and not recomended in general.

solar hound
#

I changed the product version, in the index.html file but that is also not working properly. for text I use legacy texts

astral wave
solar hound
#

I am building for a client and their users, they may not know how to hard refresh after each update on the server. I'll try to change the file names as you said.

amber ginkgo
#

Whenever you up the version, Edge will redownload the data without cache. I don't know about chrome but it should be the same story

#

you can use small version numbers for each build, like if you're on 0.1, you can add a sub for the build number like 0.1.b3, indicating it's the 3rd build

dull basalt
#

i am going to learn webgl multiplyer
any suggestions please let me know
i saw in YT there are many way to do this , which one is preferable ??

sweet oriole
amber ginkgo
#

Yeah, using Photon Fusion on a webgl game, the library works like a charm and the community is responsive

charred briar
#

Yeah essentially (disclaimer: my opinion is shared a lot but do your own research for sure):

  • Photon is kind of the gold standard, but their licensing isn't great (especially once you move away from games).
  • Normcore is second place for me but you have to do a lot to share sldata (like create 3 or 4 files just to share a score value) and lacks a lobby and relay.
  • Mirror is pretty good (and in my opinion, underrated and easiest to sync values), but you'll need to setup a relay. At least it supports a self hosted one. Each relay is a bit different though, so it's not simple to do match making sometimes.
  • Fishnet is supposed to replace mirror but... doesn't... as it is only compatible with commercial third party relays, all of which require you creating a developer account (epic, steam) or paying a service. It also takes a lot of work to just share a score between users. It relies heavily on free EOS, so if epic ever adds a dollar value to their relay, it's going to hit them hard.
  • There is the Unity service. But I don't know what it supports, their pricing model is all over, documentations pretty bad (but improving...), and then you are vendor locked to them. I love the engine, but not the company, and dont trust them with account management. Being baked in though it's slowly pushing the others out.
  • I'm currently using Nakama (self hosted, free and open source) for a large number of projects (Unity, godot, webgl and unreal) and quite happy with it. It includes a relay, user accounts, leaderboards etc. But you'll need to write a fair amount of code yourself. I have some tutorials coming 🙂
  • Dark Rift 2 is another open source one (not really maintained anymore), relay built in iirc - but convoluted process for variable sharing
  • Edgegap (relay only) is worth mentioning, trying hard, and priced more fairly than most. Documentation is very sparse.
  • Colyseus is another self hosted open source option. But it's documentation is almost non existent and is from web devs trying to make unity multiplayer. They seem to have treated data sync as an after thought.
  • Forge Networking, no longer update, authoritative. But a lot of potential. Self hosted and open source.
  • netick, makes some large speed promoses, but hasn't gained commercial interest. Requires authoritative. Doesnt support relays.

You may also find this valuable
https://github.com/StinkySteak/unity-network-library-benchmark-on-bad-network-condition?tab=readme-ov-file

It should also be mentioned photon & normcore have voice built in. And some have different network transports for web vs desktop and mobile.

Not that relays are only needed for non authoritative servers. Some like nakama also do chat, user accounts, leaderboards etc. Some do voice. Some support webgl. Some are open source... your milage may vary

GitHub

Unity Networking Library Benchmark on Bad Network Conditions - StinkySteak/unity-network-library-benchmark-on-bad-network-condition

untold field
#

I have created an open-world third-person game, but I am facing issues with deploying it as a web-based application through WebGL. I tried to deploy the project in an AWS S3 bucket, but the output is not good, and the file is almost 1 GB. I need your assistance with this.

amber ginkgo
orchid bridge
#

Mirror + Edgegap user here, i'm pretty happy with my setup. Although I do agree getting setup with Edgegap was not the easiest. As you need Docker running on your PC and have to do a bunch of steps, but I've managed to create a batch script to help automate the deployment process. Edgegap does have a Unity Plugin that supposedly makes deployment easier now. I don't use it as I have a particular deployment process that won't work with their plugin.

charred briar
#

I do have mirror running with the lightweight mirror relay at the moment, I've been benchmarking it this week. I was tempted for edgegap relay support because it is quite affordable. It's an interesting combo, I need to figure out matchmaking with it still.

My main reason for nakama is we rely on its user accounts, chat and leaderboards already, so getting the multiplayer going has been a high priority for me

orchid bridge
charred briar
#

I have to go down that path too for our non-game side 😄 it's going to be fun hah

#

You'll get a whole lot more control creatingnit yourself too though

orchid bridge
# charred briar You'll get a whole lot more control creatingnit yourself too though

Yea, it has certainly made development progress slooower having to build all this out, but now that it's all done I feel better about it. As if something breaks I don't have to wonder if it's one of the third-party services and when they'll resolve the issue. Depending on third-party services for certain things have been a nightmare for me. At least with all of these systems. Edgegap I don't mind becaus it's pretty agnostic, meaning i'm not really locked in as all it's doing is spinning up docker images of our server. So that can be replaced pretty easily compared to having codebase tighly coupled with a third-party login system, lobby, etc...

#

I guess my login system is kinda coupled with Firebase lol... but ahhh we can swap that with SQL if worse case if they ever go down. But it's a Google Service so I don't think they are going anywhere anytime soon.

#

Supposesly SupaBase is a good open-source replacement for Firebase.

charred briar
#

Yeah database switching and relay switching seems like a reasonable risk and work

orchid bridge
#

**[ HELP ] **
So i'm currently having an interesting issue where after my player logins in and we pull PlayerPreferences from database passing that to Unity Instance from the front-end using unityInstance.SendMessage it works OK, but ONLY if I reload the page 😅 !!

So what I tried to do in Unity is call PlayerPreferences.LoadPlayerPrefs(); in Awake or Start and set the Script Execution Order to the #1 on the list. But that is still not working...

#

Note in the console we can see the player preferences have loaded when I logged in... but it doesn't display the changes in the scene. Only if refresh the page will it load on the second run. PlayerPreferences.LoadPlayerPrefs(); is a custom function that is communicating with the front-end which has the player's state. Front-end responds with callback sending the state back to Unity Instance.

orchid bridge
#

nvm fixed!!! It seems there was a race condition between LoadPlayerPrefs and when my Character Customizer fetching the prefs 😅

amber ginkgo
orchid bridge
#

eventually i'd like to replace all of the in-game UI with this.

#

for now it's a blend of Unity UI and the above

forest pilot
#

that is a nice UI, does the UI look good on mobile too? I find my Unity UI just get's ruined when run on mobile browsers

#

i guess i just need 2 different UI's one for mobile and one for desktop, but I wonder if Nuxt manages stuff like that better

orchid bridge
#

I believe Unity's UI Toolkit is suppose to be based on standard web technologies so that may improve things. Although in the documentation it states there are some limitations when compared to current Unity UI. A big one for example is no support for World-space (3D) rendering.

#

So guess that means no name tags or health bars over the head of your players and NPCs.

forest pilot
#

ah cool, good to know that

forest pilot
stiff wing
#

Hello everyone!

astral wave
orchid bridge
stoic tinsel
charred briar
#

The plus side imo, is because all they've done is multiplayer engines for the last 15 years, is it is very well documented, battle tested, and reliable as can be.

pseudo sage
#

@charred briari looked into a lot of those before starting and your information seems incorrect. maybe your data is outdated? according to this chart several of the frameworks you mentioned arent even updated anymore.https://docs.google.com/spreadsheets/d/1Bj5uLdnxZYlJykBg3Qd9BNOtvE8sp1ZQ4EgX1sI0RFA/edit?gid=127892449#gid=127892449
not to mention every single networking library in your list requires a relay or dedicated server. photon, normcore, mirror, fishnet, forge, literally all of them require you to run a relay or dedicated server. how else do you get your game online?

charred briar
# pseudo sage <@229302061840203786>i looked into a lot of those before starting and your infor...

I should preface this by saying it's not really a chart, more just a few bullet points to help people get started. Photon has its own relay (they even sell it as a service), Nakama (and netick, forge & dark rift too I believe) all have it built in with their self-hosted authoritative - although Nakama is probably the most flushed out in that regard. Mirror, Normcore and Fishnet do not have a relay built in (although Mirror at least supports a self-hosted relay option - and all three could be used as a relay with an authoritative configuration). Fishnet specifically relies on EOS a lot, which I'm also not a fan of. That said, I think people should do their own research on them and use that only as a starting point. As for what is updated, I believe I pointed out which ones aren't being updated, but feel free to share a list if you like (I'm not an authority on any of this, and do not want to be). Good catch on normcore - you are right, it has no relay, I've updated it.

I should add that I like to go against the grain on this and strongly recommend self hosting a dedicated server over a cloud service (especially early on). We've run thousands of CCU's across dozens of games on our servers, and the cost is around 35/month. There isn't anything wrong with using cloud services. I think most interesting to people is which service include voice, relay, cost and self hosted. But again, it's all just personal preference.

Personally I don't like to give my data and money and control over my databases, user accounts and multiplayer to third-party companies. And some companies (like Unity) have even accidentally disabled our company accounts before because an employee hit the wrong checkbox on our account after checking our compliance - it took them 10 days before they even tried to correct it (fortunately, other people at Unity stepped in and fixed us much much sooner). I can't imagine what would have happened if we were using their ad systems, user account system and networking when that happened. But that's another story 😄

charred briar
#

Anyway, all of that to say, I strongly recommend posting a list of your own and digging into more specifics.

#

I am hoping to get some time over the next month to post walk-throughs for a few of them, the how-to of setting up a self hosted server, setting up a relay, and getting going with it. Probably the most interesting one for people will be the nakama, and I'll post my server scripts and sample projects - so it'll be really easy to kick off a VR project and own all your user data on your own systems. At least, that's the one I'd be most interested in, as it comes with leaderboards, chat, user accounts, commerce options, and authoritative. Right now, there aren't many options that can block a user from joining based on a user account (maybe UGS). Photon and Normcore for example people tend to use Playfab for user authorization. But regardless of the user being authorized or not, the servers are separate, so someone could force the connection anyway (and inject an unfavourable username). But that's another long story I suppose.

pseudo sage
#

pretty sure none of those rely on eos and can all be client authoritative or server authoritative. im a big fan of independence which is why i dont use photon but i understand their all in one alure. its risky imo to put all your eggs in one basket

#

you can authorize prior to access im pretty sure on any of the frameworks you listed too

#

the main difference is yes photon has all that built in but at a price

charred briar
#

My issue with Photon isn't the game pricing, but we have a lot of non-game clients. Which makes Unity want to charge me 5K/year/license for industry, and Photon wants 500/m/developer or something crazy for industry. So I'd rather avoid both in our non-game stuff.

pseudo sage
#

oh maybe they have a preference towards eos then? im certain its not dependent on eos at all. my goal was to use steam but i was on the fence between dedicated servers or their relays

charred briar
#

Oh yeah, it has two very solid relays for Steam. I can't remember but there is a platform it doesn't support that we use so I didn't add that one

#

With us being VR focused, Android and PlayStations important for us

#

Which only leaves us with EOS or a custom relay if we were to use fish-net.

pseudo sage
#

i do not know anything about normcore netick and a couple others you listed but the ones i do know of the tldr is to use photon if you want an all in one but be ready to commit to their eco system, or mix and match third party services with others. commiting to fusion means increased costs if your game is successful. doing it yourself means cheaper costs and experience but also more time. i suppose if someone were a very beginner id tell them to use photon so they do not stumble over other steps.

astral wave
# orchid bridge It's harder to connect code to the UI with Toolkit really? Like in comparison to...

I havent touched it for a while, but it was quite tedious, no such thing as drag an drop. You needed to use queries to find element by name and assign that way. Linking data also was kinda ... meh... I know they were working on it, especially on linking data, so idk how it is now.

Positive aspect of this kind of workflow, is that UI is totally separated from code, decoupled you could say. So it is better work flow in a long run, where changing one thing wont break everything 😉

orchid bridge
tardy hamlet
# charred briar Yeah essentially (disclaimer: my opinion is shared a lot but do your own researc...

Hi, Netick creator here. Just wanted to make a few comments.

Netick does not make any "big claims". I believe we discussed this before and came to an agreement. Both benchmarks you linked prove the "claims" you are talking about. It's the highest performing solution, in addition to the only free solution that handles bad network conditions (proven by the benchmark you linked), out of all these (included in the benchmark) options you mentioned. We are proud of that and we love to advertise this fact.

Also, server-authoritative games are the way to go now, making games that get filled with cheaters day one is a guaranteed suicide. Netick makes it as easy as client-authoritative. Free anti-cheat for all games.

Also, your analysis is subjective. Not everyone looks at solutions in terms of what relays they -currently- support. That's just one way to look at them for one specific use case. Most people are doing dedicated server games anyway where relays are completely irrelevant. And in the end making an integration with a specific service is not the hardest task ever, in fact it's relatively simple, at least with Netick.

charred briar
#

I've derailed #🌐┃web it would seem, but it's always good to get a creator to share on their passion project.

high patrol
#

It would be nice if Unity recognized the need to have a real server-authoritative net solution that isn't a bundled solution. NGO is great, but trying to hamstring it into a server auth solution is painful

hexed atlas
#

Hello folks ! Maybe some of you guys know more about how can I handle the microphone and sounds when switching tabs?

#

I have the wishes that I can still listening to my other friends when playing on a match when my focus tab is on other one that is not the actual game

astral wave
hexed atlas
rough merlin
#

Just wanted to check I dont see the Unity 2022.3.2f1 generating .unityweb file anymore even if the Compression Format is set to Gzip and Decompression Fallback is set. Any idea how to generate this file?

charred briar
#

It's (in my personal opinion) bad practices for unity to be zipping or generating gzip files anyway. If it's supported on your server, it should do it on demand. Making you do it manually is backwards. But if you want more information on the process and the way it should work and ways to handle it, this is a great guide:

sweet oriole
dull basalt
#

is there any way that someone playing webgl unity game and and this game can be stream to other website ??

wet grail
#

@umbral oracle Don't post off-topic on the server and don't spam that drama here.

umbral oracle
wet grail
#

!warn 755084025416253440 Stop posting off-topic here. Don't spam the channel.

somber questBOT
#

dynoSuccess elry.moe has been warned.

tardy hamlet
wet grail
nova stream
#

Hello, just wondering if anyone can help me understand webgl builds a bit better - Mostly interested how small can you make a webgl build, what are the common sizes and how to verify that (is the build size same as the resulting build folder on disk)? I tested building an empty 2D URP project and it seems to give me build that is around 8mb in size.

edgy mulch
#

as of unity 2022

#

without compression set up

#

thats probably as small as you can get it

nova stream
#

I was actually just browsing through this one

#

so if I read this right, you can get it around 6mb with URP as a starting point?

#

..or actually more like 7mb

sweet oriole
#

Correct. 2D template is probably adding slightly. You can reduce the build size a bit by removing unused packages (even from the minimal builds on that github page).

#

That github page is measuring "default" configurations with various settings, so you technically can go slightly lower.
Your build will still end up being many MBs either way.

#

Browser native engines (PlayCanvas, Cocos Creator) and frameworks can do a lot better, but few extra MBs can be relatively reasonable for what you get and the benefits when shipping on other platforms.

nova stream
#

What is considered a large webgl build size?

sweet oriole
#

Depends a bit on the devices/platforms (instant games) you are targeting. Looking at bounce rates for website download sizes and download time calculators at various speeds can give some indication.

#

Make sure to evaluate on demand downloading (at least for the initial screen) like Addressables if this is something you are focusing on.

nova stream
#

still keeping things relatively simple so I doubt I need addressables yet 😅

#

but this has been helpful so far so thank you!

astral wave
# nova stream but this has been helpful so far so thank you!

if you will have more than one scene, you will need addressables for sure for webgl. As without it, you download and load everything at the start, which will be undesirable in most cases (especially if you want it work on mobile web as well).

nova stream
#

ah nvm, read your comment again and now understand your point 😅

thorn flicker
#

hello im trying to get a token-exchange from the api of unity bit every time it send an error 400

$credentials = base64_encode("$keyId:$secretKey");

$url = 'https://services.api.unity.com/auth/v1/token-exchange';
$data = [

    'scopes' => ['live_ops.leaderboards.scores.get', 'live_ops.leaderboards.scores.list']
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Basic $credentials",
    'projectId' => '',
    'environmentId' => 'd',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

// Specify the path to the CA certificate bundle
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/cacert-2024-07-02.pem');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if (curl_errno($ch)) {
    echo json_encode(['error' => curl_error($ch)]);
} elseif ($status >= 400) {
    echo json_encode(['error' => "Server returned HTTP status $status"]);
} else {
    $decodedResponse = json_decode($response, true);
    if (json_last_error() === JSON_ERROR_NONE) {
        echo $response; // It's valid JSON.
    } else {
        echo json_encode(['error' => 'Invalid JSON response from server']);
    }
}

curl_close($ch);```
this is my code (i removed my project id and environementid to show it but they are set)
amber ginkgo
#

Do you get the error in a simple curl? (400 means your request syntax is invalid)

#

Had a question regarding intuitiveness of devops in webgl.
Do you guys find addressables easier to use in a webgl project that needs ~weekly devops? Or do you find AssetBundles better for the web? (Given addressables' RAM peak when loading as well as the inability to load from bytes)

astral wave
#

the real question is... is scarf on the character is cloth physics or just animations?

orchid bridge
dull basalt
#

does photon pun 2 work in webgl ??
cause mine not working , did i need quantum 3 for that ??

orchid bridge
dull basalt
#

thats why i think its not working

hoary raven
carmine granite
#

does anyone know how to embed an unity game onto an html page

sweet oriole
carmine granite
sweet oriole
forest pilot
#

what is a good database solution for non-local storage? I was about to use Firebase real-time database but then learned that it isn't really compatible with WebGL (there is an old unity package someone made with webGL support but its not been updated for 3 years and i don't see much signs of life there)

astral wave
elfin trail
#

hi

forest pilot
#

hi

obtuse loom
#

<@&502884371011731486> this looks shady AF...

#

ignoring my comment just makes this even shadier...

frank lynx
#

!ban 1237086828364828694 Some weird bot messaging?

somber questBOT
#

dynoSuccess rex12__23 was banned.

obtuse loom
#

🦾

odd snow
#

Hey Team,

I am using web gl build, and i am using asset free outline shader.
This only happens on webgl, but not in desktop build.

Any advice idea how to solve this ui glitch?

obtuse loom
#

how should it look? 🤔

odd snow
#

without this red glitching

#

just red outline

versed crater
#

Does WebGL have a light count limit even when using deferred rendering?

forest pilot
#

i dont see how there would be a limit

#

i guess it just depends on what the machine can handle

versed crater
# forest pilot i dont see how there would be a limit

Just confused - I ran into the 8 light limit with forward rendering in the editor, so I switched to forward+. But WebGL doesn't support it, so I tried deferred. It looks good in the editor, but the web build looks a lot like the 8 light limit I had first.

astral wave
# versed crater Just confused - I ran into the 8 light limit with forward rendering in the edito...

if you are using more than 8 light sources on your webgl project, you already doing something wrong. Reason is that webgl is very performance not friendly, and calculating lights is quite expensive, if not the most expensive thing to do. I strongly suggest bake lights, and have max 1 real time lighting in the scene if any. also have in mind Webgl dont have global illumination what so ever, so if you set that, editor and build will always looks different.

While webgl 2 supports differed rendering pipe line, if you some why running webgl 1 it will automatically run in forward renderring instead. And if I remember correctly differed is less performant than forward, unless there specific scenarios present.

Another tip if you insist in running a lot of lights, you can cheat in cutting objects in smaller pieces, as 8 ligths limit is per object. So as long one object is not effected by all lights, it will be fine.

astral wave
# odd snow Hey Team, I am using web gl build, and i am using asset free outline shader. Th...

does asset states that they support webgl? if not, you should search for another asset. Reason is it really depends how they created shader, and gussing how to fix it might be complicated. In the end you might need to create outline effect by your self, in URP there are multiple ways how to do it. Sorry I know it not big help, but webgl is very sensitive to a lot of things and hard to say where it went wrong. Next time you also could name asset name for more info. Some asset owners have quite decent support.

odd snow
#

webgl can not support 4000 basic cubes? why is the game failing to load with no EM_asm constant found

scenic narwhal
#

Hey

#

I added a button on my WebGL app but I can't communicate with it, I can't write in it. Why ?

<div>
    <div>
      <label for="session-id">Session ID:</label>
      <input type="text" id="session-id">
    </div>
    <div>
      <label for="lap-number">Lap Number:</label>
      <input type="number" id="lap-number">
    </div>
    <div>
      <button onclick="SendMessage('APIManager', 'LoadLapData', '')">Load Lap Data</button>
    </div>
    </div>```
#

Conflicts with Javascript from Unity ?
If yes, how can I fix that ?

versed crater
charred briar
orchid bridge
# scenic narwhal Conflicts with Javascript from Unity ? If yes, how can I fix that ?

You can't just call SendMessage, you'll need to reference the Unity Instance chained with the method

Like shown here: https://docs.unity3d.com/Manual/web-interacting-browser-unity-to-js.html

now the tricky thing is even if you did that directly on the onclick I believe you may get an error because the Unity instance hasn't loaded yet.

So in the order of things... HTML elements load first and if onclick is referencing an undefined instance of an object it will error!

So you'll need to create a let variable in global scope of your javascript where you'll later assign the Unity instance to once it's available.

then you need another function in your global scope that serves as a wrapper function that handles the send message on the unity instance.

function SendMessage() {
unityInstance.SendMessage()
}

finally when you pass arguments to the SendMessage, Unity is very sensitive about what you pass it. So if you have nothing to pas in the third argument, don't include it.

If you just want to call a C# function on Unity object then just call it like this

unityInstance.SendMessage('object', 'function name')

#

If all the above doesn't make sense to you... share your webgl build with the web content on a site like https://codesandbox.io and I can then help edit it for ya and show you how to set this all up

CodeSandbox

CodeSandbox is a cloud development platform that empowers developers to code, collaborate and ship projects of any size from any device in record time.

narrow knot
#

can i share my off topic project here?

wet grail
narrow knot
#

its not made with unity

wet grail
#

Then find any non-dedicated-Unity game dev community to post it in?

narrow knot
#

why dont have a off topic channel

narrow knot
#

ok thats a good reason to dont have off topic channel

charred briar
#

There is the indiegames discord too that's smaller but growing.

obtuse loom
#

any idea where to set the USE_THREADS flag in webgl builds? 🤔

random talon
#

If I want the unity window embedded into a website to be rounded, can I make it directly by its build index.html?

scenic narwhal
#

😔

orchid bridge
scenic narwhal
#

Nope

#

I can select it but when I type in it, nothing happen and nothing is displayed

#

If I comment the canvas, I can. So I thought it's because the key inputs are for the unity app

orchid bridge
orchid bridge
scenic narwhal
#

I think it is related to that maybe...

#

Not sure at 100% but probably the case

orchid bridge
scenic narwhal
#

Thank you 🙏

orchid bridge
#

I'm actually toggling this on and off at certain points in my game as well

#

I believe main menu it's set to false

#

then in-game I set it to true

scenic narwhal
#

Oh, thank you a lot, it worked

#

I didn't know that and I didn't found that on internet

orchid bridge
#

I forget how I found it... but yea I struggled with this before!! so happy it worked for ya

astral wave
# obtuse loom any idea where to set the `USE_THREADS` flag in webgl builds? 🤔

go to your project folder->ProjectSettings-> open ProjectSettings.asset with any text editor and set webGLThreadsSupport to 1. Start your projet you will see that there will be now threading supported. Please have in mind, that this threading is just for c++ and not for c#. So just enabling it wont make everything just work.

obtuse loom
astral wave
languid drum
#

what is the best texture compression to use for webgl? I'm interested in the least loss of quality and small size and that it is supported on all devices

astral wave
# languid drum what is the best texture compression to use for webgl? I'm interested in the lea...

Answer "there is none" that is the best for all devices.
https://docs.unity3d.com/Manual/class-TextureImporterOverride.html
Each device supports different compression, and if it fails it fallbacks to back to RGBA. Ideally you would want to have separate build of each of device like it is done here, but well in more complicated way:
https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-texture-compression.html

If you want to stick with one compression format I would go with ASTC6x6. It is bit bigger than ETC2 or DXT, but it will work on iPhones and Android. Well PC will have to fallback to RGBA, but PC have most free resources so it can suffer a bit. Enjoy webgl suffering 🙂

random talon
#

Im trying to test different background musing for my webgl game, I have a simple ui panel that changes the audioclip of an audiosource by pressing different buttons.
The problem is that on WebGL (and not in editor) the music takes quite a while to start

#

Can I somehow remove this delay?

lime kelp
#

Hi guys,

Has anyone here ever successfully modified the AudioContext in WebGL through a JSLIB for audio mixing?

I've tried to capture the context with a JSLIB but because Unity creates what seems like a hardcoded context object with no exposed API to use it, it seems like I have to modify engine level code to reach it?

Any help or pointers would be appreciated!

astral wave
astral wave
# lime kelp Hi guys, Has anyone here ever successfully modified the **AudioContext** in Web...

I might not help a lot, but from hat I know you are pretty much right, you cannot reach audio context from JSLIB. I saw plugins that was able to do so, but they used c# code to parse information between Unity and external calls. For example webrtc voice chat plugin. There are a lot of reason why Unity does it this way even if that is inconvenient. I would suggest either handle all audio that needs JSLIB access outside of unity in js code (just call js code from unity and trigger unity code from js). Or you will need to write elaborate plugin your self. If that plugin is core part of your project, I might even move to PlayCanvas to hav easy access to all audio from JS

lime kelp
obtuse loom
#

Template variables, macros, and conditional directives

During the build process, Unity pre-processes template files and evaluates all macros and conditional directives included in those files. As part of this process, Unity finds and replaces all macro declarations with the values the Editor supplies. Unity automatically pre-processes all .html, .php, .css, .js and .json files in the template folder.
https://docs.unity3d.com/Manual/webgl-templates.html

Do we know what template language/engine unity is using? 🤔
I get we can use #if and {{{ STUFF }}} but do we have other tools?

sweet oriole
obtuse loom
#

you are right 🥲
it's done in javascript...
it's not using any of the javascript templating libraries
mustache, handlebars, dot, ejs, nunjucks, underscore, pug, hogan, and many more...
NOPE, just a regex locals.output.replace(/{{{([^}]|}(?!}))+}}}/g, ...

agile marten
#

Long error pops up starting with "
"An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
RuntimeError: indirect call to null""

It all worked fine earlier

charred briar
#

It could really be a lot of things

#

I'd also do a debug build with development logging of everything enabled etc.

agile marten
charred briar
#

You'll need to go through the build settings and player settings and just turn on max logging, development mode, and uncompressed.

#

Basically anything that will give you more info

agile marten
#

On it

#

Man this sucks lol
The other levels work

#

Actually idk how to do that and I don't wanna mess things up more than they are rn. I'll try it fresh tomorrow

agile marten
#

Fixed! It was some weird script I had checked

eternal kernel
#

Excuse me! 🙂
deleted it.

fervent drum
#

Im trying to build my game to HTML5 for the gmtk jam and there is a bug that seems to only affect the web version where when i go into fullscreen, all the text in the game goes invisible.
it only happens when i attack an enemy, and the only code todo with text is this:

        GameObject popupGUI = Instantiate(player.damagePopup, new Vector2(UnityEngine.Random.Range(position.x - 0.30f, position.x + 0.30f), position.y + 0.5f), Quaternion.identity);
        popupGUI.GetComponentInChildren<TextMeshPro>().text = popup;
        
        popupGUI.GetComponentInChildren<TextMeshPro>().faceColor = color;
        popupGUI.GetComponentInChildren<TextMeshPro>().color = Color.white;
        yield return new WaitForSeconds(0.84f);
        Destroy(popupGUI);

why is this happening? ive been trying to fix it for a few hours now

umbral hinge
#

Any idea why my WebGL is build is freezing up the whole browser on Windows, but is fine on Linux?

cunning elm
#

Hi! I'm trying to do a WebGL build and i'm getting this error - IL2PP error for method '...' System.NullReferenceException: Object Reference not set to an instance of an object. There are no compiler errors and everything runs fine in the editor. Could someone please suggest any fixes? I wasn't able to find a lot online

arctic rose
#

Show the full error message

cunning elm
#

This is the full debug

dusk star
#

I have two video players in a scene. If I play both only one player is rendered. Other one is definetly playing because I can hear the audio, but not rendered. If I pause the first one, second is rendered. If I play the first one again, second stops rendering but still playing. In standalone/editor everything works properly, this happens only in WebGL. Do any of know why this is happening ? I use RenderTexture and assigning it to a material which is assigned to mesh in which the video is rendered. I create the RenderTexture runtime and instantiate the material runtime too.

astral wave
dusk star
astral wave
dusk star
languid drum
fallow iron
#

I'm getting a strange error trying to deploy my project to WebGL. Has anyone else encountered this?

astral wave
fallow iron
fallow iron
sonic violet
#

I have a full screen Canvas, can I still set something like max Resolution, because I dont need it to run on 4k, it is enough to be FullHD and then scale. Is there an easy way I am missing?

languid drum
#

How to remove unity logo from WebGL build??

I remove checkbox from Show unity logo and use Default WebGL template

mossy bridge
#

hello

#

I`m getting this error when bulding the game for web

ripe sluice
# mossy bridge

you can try using the unity build and run option, as they mentioned - this makes unity host the game for you

ripe sluice
# mossy bridge Okay I will try

you basically need a web server to run a game, and right now you have none
Unity can kinda act like one for the purposes of running the game

ripe sluice
#

but I'd use build-and-run as a sanity check first

mossy bridge
#

I will die notlikethis

ripe sluice
#

or are you just happy it worked xd

mossy bridge
mossy bridge
ripe sluice
mossy bridge
gilded sage
#

anyone get this error before in specficially webgl builds?

astral wave
# gilded sage

it really better to check browser console for more detailed error message. Most likely it just null reference somewhere in your code.

forest coral
#

Hello gm

plucky lotus
#

!ide

somber questBOT
gilded sage
#

webgl just doesn't work with HttpClient in .NET

#

it's fine, didn't really need webgl as a target

sweet oriole
languid drum
#

how to fix this parse error?

sweet oriole
languid drum
languid drum
orchid bridge
#

so i was trying WebGPU for the first time and tried to build an empty scene but after the build i get dark screen then nothing

#

when i reload the page, the unity logo loader show up but then the dark scene again and nothing

charred briar
#

Probably a good idea to check the console for errors

cinder furnace
#

Trying to Build and Run my WebGL game I get a gray screen, just like the last message above, here's my console log, I searched a few of the errors without success, anyone knows what it could be?

1.framework.js.gz:10 RuntimeInitializeOnLoadManagerInitializer: Failed reading 'ScriptingAssemblies.json'
1.framework.js.gz:10 [Physics::Module] Initialized SinglethreadedJobDispatcher.

1.framework.js.gz:10 No GlobalGameManagers file was found at , quitting player!

1.framework.js.gz:10 Failed to initialize player

1.loader.js:1 [UnityCache] 'http://localhost:58401/Build/1.data.gz' successfully downloaded and stored in the indexedDB cache
cinder furnace
#

What's weird is that when I read online, people will usually have some other error causing theses, or am I missing something?

cinder furnace
#

Turns out I could enable more stack traces in build settings and then that all made sense

stoic tinsel
#

Anyone have IAPs on iOS/android who has a good solution for either letting people buy iaps in a self hosted web version of the game (stripe??).

#

Code/selfhost answers only, eg not revenuecat.

sweet oriole
stoic tinsel
#

WebGL will only garbage collect at the end of the frame - it can't do so mid-frame. That's fine, but... if I turn my expensive loop into an async Awaitable, and periodically

await Awaitable.NextFrameAsync()

Can the garbage collector run then and clean up all the garbage from previous iterations of the loop? Because on WebGL it doesn't look like it is... (Previously there were problems in Unity with using Task.Delay() etc not allowing the garbage collector to run on any platforms - you ended up having to use coroutines. It looks like Awaitable has fixed that, but not on web...)

sterile burrow
#

Im building for WebGL and it works fine on all platforms but reloads twice on iOS then nothing happens. The first time it loads, it will load the first (loading) scene, but the moment it should transition in to the main scene, it will reload. Anyone experienced this before? I read about a 500MB limit for RAM, but it does load the first scene, and sometimes (rarely) the full scene too, and it will vary between 500MB and 1.5gb in JS memory through checking the console.

Which is also weird, how wildly it can vary..

Again, works on all platforms except for iOS

astral wave
# sterile burrow Im building for WebGL and it works fine on all platforms but reloads twice on iO...

Welcome to webgl iOS hell. iOS have a lot of hidden rules that are not obvious. Are you using addressables or other assets management tool? As by default even if you load only first scene, everything will be loaded to memory regardless of scene loaded. My guess would be memory limit, most likely it gives too low start memory, then reloads and gives more memory then it works. You can play with ho memory is increased in newer Unity versions. But iOS, depending on device have memory limits for UnityWebgl, for example iOS 10 will have start weird behavior at around 400~mb RAM (if you use UI toolkit the ui starts blinking), then around 500 MB starts restarting or doesnt load at all. On never devices it is bit better, but still you must be VERY carefull with memory on iOS. Surprisingly PlayCanvas don't have this memory problem, but that is not Unity fault, iOS is just.... well.... hell to develop at.

sterile burrow
craggy ruin
#

Anyone know why my game crashes on mobile webGL? My build is kinda big could that be a reason? If you need more info tell me.

sterile burrow