53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
|
using Netcode.Transports.Facepunch;
|
||
|
using Steamworks;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Unity.Netcode;
|
||
|
using Unity.Netcode.Transports.UTP;
|
||
|
using Unity.VisualScripting;
|
||
|
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<UnityTransport>();
|
||
|
NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport;
|
||
|
|
||
|
NextScene();
|
||
|
}
|
||
|
|
||
|
private void OnSteamClicked()
|
||
|
{
|
||
|
LoadingText.SetActive(true);
|
||
|
ButtonsHolder.SetActive(false);
|
||
|
var transport = NetworkManager.Singleton.gameObject.AddComponent<FacepunchTransport>();
|
||
|
NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport;
|
||
|
|
||
|
NextScene();
|
||
|
}
|
||
|
|
||
|
private void NextScene()
|
||
|
{
|
||
|
int currentScene = SceneManager.GetActiveScene().buildIndex;
|
||
|
SceneManager.LoadScene(++currentScene);
|
||
|
}
|
||
|
}
|