Replace legacy UI components with TextMeshPro for improved text rendering and flexibility. Update component references and properties to ensure compatibility with the new text system. This change enhances visual quality and performance in the menu scene.
34 lines
804 B
C#
34 lines
804 B
C#
using UnityEngine;
|
|
using Unity.Netcode;
|
|
|
|
public class HostTestingEnv : MonoBehaviour
|
|
{
|
|
void Start()
|
|
{
|
|
StartHost();
|
|
}
|
|
|
|
void StartHost()
|
|
{
|
|
// Ensure NetworkManager is initialized
|
|
if (NetworkManager.Singleton == null)
|
|
{
|
|
Debug.Log("NetworkManager is not initialized. Cannot start host.");
|
|
return;
|
|
}
|
|
|
|
// Subscribe to the client connected event
|
|
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected;
|
|
|
|
// Start the host (server + client)
|
|
NetworkManager.Singleton.StartHost();
|
|
Debug.Log("Host started!");
|
|
}
|
|
|
|
void OnClientConnected(ulong clientId)
|
|
{
|
|
string message = $"Player with Client ID {clientId} connected.";
|
|
Debug.Log(message);
|
|
}
|
|
}
|