Unity player accounts cannot log in in webgl

Excuse me, I made a complete project, which was originally suitable for the andriod platform, but I wanted to convert it into a web game, so I converted it to webgl, and then after building and running, after starting the web page, I found that after clicking The login button has no response, even though it works fine when I try it in the unity editor. I use unity player accounts as login method.
Does Unity player accounts not support webgl? Or am I doing something wrong somewhere.
Thanks for anyone’s answer.

likely there will be something in the console, such as cors

1 Like

You may want to post your code.

WebGL has some slightly different behaviour particularly around awaitable async methods in my experience. It’s single-threaded so perhaps what used to happen within the same frame is now delayed, and that may come at a surprise.

Anyway, Player Auth works in Web. Can’t hurt to check for editor and package updates though and try those.

1 Like
 private async void Awake()
    {
        await UnityServices.InitializeAsync();
        PlayerAccountService.Instance.SignedIn += SignedIn;
        await CheckSignInStatus();
    }

When I tried to initialize services in webgl this way, I got an error that services cannot be initialized in another thread. Do you have any errors in the developer console?

Check if you have package updates available, any services package not just Authentication. If so, try with the update.

Do note that you ABSOLUTELY have to try/catch any and all service calls! Any of them may fail for whatever reason and your app must be able to handle this gracefully, be it “no internet” or “servers down” or any other issue. You don’t want your app to crash on users “randomly” but rather show a “failed to login” message.

This goes for any I/O operation in principle, be it a file or remote location.

Thanks for your reply!
Thank you, I will use try and catch more in the future. Take notes ^ ^.
I updated all the packages that could be updated, and then, things progressed a little bit, and I could jump to the mainmenu scene, but a new error appeared, and it looked like my login logic was failing on webgl.
error:
CloudSaveException: Player ID is missing - ensure you are signed in through the Authentication SDK and try again.
at Unity.Services.CloudSave.Internal.PlayerDataApiClient.ValidateRequiredDependencies () [0x00000] in <0000000000000000000000000000000>:0

I’ve seen similar questions elsewhere on the forum and am wondering if there are still answers to this question.