My total code can be found here: private Unity.Services.Lobbies.Models.Lobby hostLobby; private Unity.Se - Pastebin.com
I get a null reference error when ever I try to access the data in a PlayerDataObject.
private void ListPlayers()
{
try
{
Debug.Log("Listing Players in " + joinedLobby.Name);
//Debug.Log(joinedLobby.Players[0].Data.);
foreach (Player player in joinedLobby.Players.ToArray())
{
Debug.Log(player.Data["playerName"].Value + " " + player.Id); <---
}
} catch (LobbyServiceException e)
{
Debug.LogError(e);
}
}
I put the data in the player object with the GetPlayer() method:
private Player GetPlayer(string playerName)
{
return new Player
{
Data = new Dictionary<string, PlayerDataObject>
{
{ "playerName", new PlayerDataObject(PlayerDataObject.VisibilityOptions.Public, playerName) }
}
};
}
I have no idea what to do because I have never used DataObjects before now.
Any help would be greatly appreciated.