Hi,
I’m trying to make Lobby work but I have an issue when building my game.
I have a UGSManager.cs which logs player in and call
await UnityServices.InitializeAsync();
Then, I have a button that create a Lobby with the following code:
public async Task CreateLobby(string lobbyName, int maxPlayer, Dictionary<string, DataObject> datas = null, bool isPrivate = true)
{
try
{
Debug.LogError($"<color=#FFA500>[UGSLobbyManager]</color> <color=#7999ea>[CreateLobby]</color> => START creating lobby {lobbyName}.");
CreateLobbyOptions options = new CreateLobbyOptions();
options.IsPrivate = isPrivate;
options.Data = datas;
CurrentLobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayer, options);
RegisterLobbyEventCallbacks();
Debug.LogError($"<color=#FFA500>[UGSLobbyManager]</color> <color=#7999ea>[CreateLobby]</color> => END creating lobby {lobbyName}.");
}
catch (LobbyServiceException e)
{
Debug.LogError($"<color=#FFA500>[UGSLobbyManager]</color> <color=#7999ea>[CreateLobby]</color> => ERROR creating lobby {lobbyName}. Error message : {e.Message} | {e.ErrorCode} | {e.Reason} | {e.ApiError}");
}
When I test this in editor, it works fine (the lobby is created as it should).
But when I build my game and try the same thing on the built version, I have the following error:
Unable to get ILobbyServiceSdk because Lobby API is not initialized. Make sure you call UnityServices.InitializeAsync().
I’ve tried to place the UnityServices.InitializeAsync() in the CreateLobby function, just in case something went wrong in the Authentication, but the same message appears. I have Friends working fine, so it looks like UnityServices is correctly initialized.
Does someone have any idea on what might be the issue?