RateLimiting causing silent exeption which causes AddPlayerScoreAsync to fail.


When executing AddPlayerScoreAsync via Task.Run, Unity throws an exception:

Task.Run(async () => { await LeaderboardsService.Instance.AddPlayerScoreAsync(leaderboardID, score); });

"UnityEngine.UnityException: get_unscaledTime can only be called from the main thread."

Originating from

public bool RateLimited => Time.unscaledTime < m_rateLimitUntilUnscaledTime;

As a result, the submission is silently swallowed and never occurs.

Just noticed you can happily just call async methods in Unity, as long as you don't need the return immediately (which I don't). So that works perfectly fine. Sorry for the confusion!


1 Like

Hi Chris,

Great job! Just to provide a bit more information, the exception is actually intentional. Web requests must be made from the main thread, which is why this exception occurs.

Thank you,