online game working

This commit is contained in:
2025-10-05 19:24:52 +02:00
parent 7cec95b8a0
commit dd89012919
3 changed files with 77 additions and 11 deletions

View File

@@ -366,7 +366,30 @@ namespace MegaKoop.UI
servicesRoot.AddComponent<SteamManager>();
}
T EnsureComponent<T>() where T : Component
{
if (servicesRoot.TryGetComponent<T>(out var existing))
{
return existing;
}
#if UNITY_2023_1_OR_NEWER
var found = Object.FindFirstObjectByType<T>(FindObjectsInactive.Include);
#else
var found = Object.FindObjectOfType<T>();
#endif
if (found != null)
{
return found;
}
return servicesRoot.AddComponent<T>();
}
EnsureComponent<SteamLobbyManager>();
EnsureComponent<SteamP2PTransport>();
EnsureComponent<SteamCoopNetworkManager>();
lobbyGameCoordinator = servicesRoot.GetComponent<LobbyGameSceneCoordinator>() ?? servicesRoot.AddComponent<LobbyGameSceneCoordinator>();
DontDestroyOnLoad(servicesRoot);
}
}