Hey there again!
I’ve come so far and am able to create a Lobby as a Host, everything works basically, except for the Client who joins the lobby by accepting the invitation from host, but the UI doesnt Update whatsoever…
I’m not sure what I’m missing, its probably a small line of code, but I cant seem to find it…
Also, does the client start the game and sit on menu until accepting, or does he have to close the game completely and then accept the invitation?
here is my menu code:
using Mirror;
using Steamworks;
using UnityEngine;
using UnityEngine.SceneManagement;public class Menu : MonoBehaviour
{[SerializeField] private GameObject landingPagePanel = null; [SerializeField] private GameObject lobbyPanel = null; [SerializeField] private bool useSteam = false; private const string HostAddressKey = "HostAddress"; protected Callback<LobbyCreated_t> LobbyCreated; protected Callback<GameLobbyJoinRequested_t> GameLobbyJoinRequested; protected Callback<LobbyEnter_t> LobbyEntered; public static CSteamID LobbyId { get; private set; } private void Start() { if (!useSteam) return; LobbyCreated = Callback<LobbyCreated_t>.Create(OnLobbyCreated); GameLobbyJoinRequested = Callback<GameLobbyJoinRequested_t>.Create(OnGameLobbyJoinRequested); LobbyEntered = Callback<LobbyEnter_t>.Create(OnLobbyEntered); } public void HostLobby() { landingPagePanel.SetActive(false); if (useSteam) { lobbyPanel.SetActive(true); SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypeFriendsOnly, 4); return; } NetworkManager.singleton.StartHost(); } public void PlayGame() { SceneManager.LoadScene("gameScene"); } public void QuitGame() { Debug.Log("Quit"); Application.Quit();
}
private void OnLobbyCreated(LobbyCreated_t callback) { if (callback.m_eResult != EResult.k_EResultOK) { lobbyPanel.SetActive(false); landingPagePanel.SetActive(true); return; } NetworkManager.singleton.StartHost(); LobbyId = new CSteamID(callback.m_ulSteamIDLobby); SteamMatchmaking.SetLobbyData( LobbyId, HostAddressKey, SteamUser.GetSteamID().ToString()); } private void OnGameLobbyJoinRequested(GameLobbyJoinRequested_t callback) { SteamMatchmaking.JoinLobby(callback.m_steamIDLobby); } private void OnLobbyEntered(LobbyEnter_t callback) { if (NetworkServer.active) return; string hostAddress = SteamMatchmaking.GetLobbyData( new CSteamID(callback.m_ulSteamIDLobby), HostAddressKey); NetworkManager.singleton.networkAddress = hostAddress; NetworkManager.singleton.StartClient(); landingPagePanel.SetActive(false); lobbyPanel.SetActive(true); }
}
If you need any more code to figure out what wrong, please let me know.
Cheers