using Netcode.Transports.Facepunch; using Unity.Netcode; using Unity.Netcode.Transports.UTP; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class NetworkSetup : MonoBehaviour { [SerializeField] private Button LocalBtn; [SerializeField] private Button SteamBtn; [SerializeField] private GameObject ButtonsHolder; [SerializeField] private GameObject LoadingText; private void OnEnable() { LocalBtn.onClick.AddListener(OnLocalClicked); SteamBtn.onClick.AddListener(OnSteamClicked); } private void OnLocalClicked() { LoadingText.SetActive(true); ButtonsHolder.SetActive(false); var transport = NetworkManager.Singleton.gameObject.AddComponent(); NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport; NextScene(); } private void OnSteamClicked() { LoadingText.SetActive(true); ButtonsHolder.SetActive(false); var transport = NetworkManager.Singleton.gameObject.AddComponent(); NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport; NextScene(); } private void NextScene() { int currentScene = SceneManager.GetActiveScene().buildIndex; SceneManager.LoadScene(++currentScene); } }