online game working
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user