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); } }