Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplayer fixes #809

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Assets/Scripts/GUI/MultiplayerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public string RoomName
{
data.roomName = value;
UpdateDisplay();
SaveRoomName(value);
}
}

Expand Down Expand Up @@ -82,7 +83,7 @@ public void Awake()
{
data = new RoomCreateData
{
roomName = GenerateUniqueRoomName(),
roomName = "default room",
mikeage marked this conversation as resolved.
Show resolved Hide resolved
@private = false,
maxPlayers = 4,
voiceDisabled = false
Expand Down Expand Up @@ -111,13 +112,23 @@ private void OnLanguageChanged(Locale newLocale)
updateDisplay = true;
}

public async void RetrieveRoomName()
{
var storedRoomName = await m_multiplayer.GetAsync<string>("roomname");
RoomName = storedRoomName ?? GenerateUniqueRoomName();
}

private async void SaveRoomName(string roomName)
{
await m_multiplayer.StoreAsync("roomname", roomName);
}

public async void RetrieveUsername()
{
var storedNickname = await m_multiplayer.GetAsync<string>("nickname");
NickName = storedNickname ?? "Unnamed";
}


private async void SaveNickname(string nickname)
{
await m_multiplayer.StoreAsync("nickname", nickname);
Expand All @@ -129,6 +140,7 @@ protected override void OnEnablePanel()

m_multiplayer = new PlayerPrefsDataStore("Multiplayer");
RetrieveUsername();
RetrieveRoomName();

if (MultiplayerManager.m_Instance == null) return;
if (MultiplayerManager.m_Instance.State == ConnectionState.INITIALIZED || MultiplayerManager.m_Instance.State == ConnectionState.DISCONNECTED)
Expand Down
Loading