using UnityEngine; using Unity.Netcode; namespace Northbound { /// /// Quick test to verify NetworkManager is working and accessible /// public class NetworkManagerQuickTest : MonoBehaviour { [Header("Test Settings")] [SerializeField] private bool runTestOnStart = true; [SerializeField] private bool showDetailedLogs = true; private void Start() { if (runTestOnStart) { RunQuickTest(); } } [ContextMenu("Run Quick NetworkManager Test")] public void RunQuickTest() { Debug.Log("=== NETWORKMANAGER QUICK TEST ==="); TestNetworkManagerExists(); TestPlayerPrefab(); TestTransport(); TestConnectionHandlers(); Debug.Log("=== TEST COMPLETE ==="); } private void TestNetworkManagerExists() { Debug.Log("[1/4] Testing NetworkManager Existence..."); NetworkManager nm = NetworkManager.Singleton; if (nm == null) { Debug.LogError("✗ NetworkManager.Singleton is NULL!"); Debug.LogError("This means:"); Debug.LogError("1. NetworkManager GameObject is not in scene"); Debug.LogError("2. NetworkManager component is missing"); Debug.LogError("3. NetworkManager hasn't been initialized yet"); return; } Debug.Log("✓ NetworkManager found!"); Debug.Log(" IsServer: " + nm.IsServer); Debug.Log(" IsClient: " + nm.IsClient); Debug.Log(" IsHost: " + nm.IsHost); Debug.Log(" IsConnectedClient: " + nm.IsConnectedClient); Debug.Log(" LocalClientId: " + nm.LocalClientId); } private void TestPlayerPrefab() { Debug.Log("[2/4] Testing Player Prefab..."); NetworkManager nm = NetworkManager.Singleton; if (nm == null) { Debug.LogError("✗ Can't test - NetworkManager is null"); return; } if (nm.NetworkConfig == null) { Debug.LogError("✗ NetworkConfig is null!"); return; } GameObject playerPrefab = nm.NetworkConfig.PlayerPrefab; if (playerPrefab == null) { Debug.LogError("✗ Player Prefab is NOT assigned!"); Debug.LogError("→ This is the #1 reason servers don't start!"); Debug.LogError("→ FIX: Select NetworkManager → Network Config → Player Prefab"); Debug.LogError("→ Drag your Player Prefab from Project to that field"); return; } Debug.Log("✓ Player Prefab assigned: " + playerPrefab.name + ""); var networkObject = playerPrefab.GetComponent(); if (networkObject == null) { Debug.LogWarning("⚠ Player Prefab has NO NetworkObject!"); Debug.LogWarning("→ Add NetworkObject component to Player Prefab"); } else { Debug.Log("✓ Player Prefab has NetworkObject"); } } private void TestTransport() { Debug.Log("[3/4] Testing Unity Transport..."); NetworkManager nm = NetworkManager.Singleton; if (nm == null) { Debug.LogError("✗ Can't test - NetworkManager is null"); return; } var transport = nm.GetComponent(); if (transport == null) { Debug.LogError("✗ Unity Transport not found on NetworkManager!"); Debug.LogError("→ FIX: Add Unity Transport component to NetworkManager GameObject"); return; } Debug.Log("✓ Unity Transport found!"); Debug.Log(" Port: " + transport.ConnectionData.Port); Debug.Log(" Address: " + transport.ConnectionData.Address); Debug.Log(" ServerListenAddress: " + transport.ConnectionData.ServerListenAddress); if (transport.ConnectionData.Port <= 0) { Debug.LogWarning("⚠ Transport Port is not set (0)!"); Debug.LogWarning("→ FIX: Set Port to 40445 in Unity Transport component"); } if (transport.ConnectionData.Address == "127.0.0.1") { Debug.LogError("✗ Transport Address is 127.0.0.1!"); Debug.LogError("→ This BLOCKS all remote connections!"); Debug.LogError("→ FIX: Change Address to 0.0.0.0"); } else if (transport.ConnectionData.Address == "0.0.0.0") { Debug.Log("✓ Transport Address is 0.0.0.0 (accepts all connections)"); } } private void TestConnectionHandlers() { Debug.Log("[4/4] Testing Connection Handlers..."); NetworkConnectionHandler handler = FindObjectOfType(); if (handler == null) { Debug.LogWarning("⚠ NetworkConnectionHandler not found!"); Debug.LogWarning("→ Manual player spawning may not work"); Debug.LogWarning("→ FIX: Add NetworkConnectionHandler component to scene"); return; } Debug.Log("✓ NetworkConnectionHandler found!"); Debug.Log("→ Manual player spawning should work"); PlayerSpawnPoint[] spawnPoints = FindObjectsByType(FindObjectsSortMode.None); if (spawnPoints.Length > 0) { Debug.Log("✓ Found " + spawnPoints.Length + " Player Spawn Point(s)"); } else { Debug.LogWarning("⚠ No Player Spawn Points found!"); Debug.LogWarning("→ Players may spawn at default position"); } } [ContextMenu("Generate Setup Report")] public void GenerateSetupReport() { Debug.Log("=== NETWORKMANAGER SETUP REPORT ==="); Debug.Log(""); Debug.Log("CURRENT STATUS:"); NetworkManager nm = NetworkManager.Singleton; if (nm == null) { Debug.LogError("NetworkManager: NOT FOUND (NULL)"); Debug.LogError(""); Debug.LogError("CRITICAL ISSUE:"); Debug.LogError("1. NetworkManager GameObject not in scene"); Debug.LogError("2. NetworkManager component missing"); Debug.LogError("3. NetworkManager not initialized"); Debug.LogError(""); Debug.LogError("QUICK FIX:"); Debug.LogError("1. Check your scene for NetworkManager GameObject"); Debug.LogError("2. Add NetworkManager component if missing"); Debug.LogError("3. Check Console for initialization errors"); } else { Debug.Log("NetworkManager: FOUND"); Debug.Log("IsServer: " + nm.IsServer); Debug.Log("IsClient: " + nm.IsClient); Debug.Log("IsHost: " + nm.IsHost); if (nm.NetworkConfig != null) { GameObject playerPrefab = nm.NetworkConfig.PlayerPrefab; if (playerPrefab == null) { Debug.LogError(""); Debug.LogError("⚠ CRITICAL: Player Prefab NOT assigned!"); Debug.LogError("This is the #1 cause of servers not starting!"); Debug.LogError(""); Debug.LogError("FIX IMMEDIATELY:"); Debug.LogError("1. Select NetworkManager in scene"); Debug.LogError("2. Inspector → Network Config → Player Prefab"); Debug.LogError("3. Drag Player Prefab from Project to that field"); } else { Debug.Log("Player Prefab: ASSIGNED (" + playerPrefab.name + ")"); } } var transport = nm.GetComponent(); if (transport != null) { Debug.Log("Transport Port: " + transport.ConnectionData.Port); Debug.Log("Transport Address: " + transport.ConnectionData.Address); } else { Debug.LogError("Unity Transport: NOT FOUND"); } } Debug.Log(""); Debug.Log("NEXT STEPS:"); Debug.Log("1. If Player Prefab is NULL: Assign it immediately!"); Debug.Log("2. Check NetworkManagerValidator → Validate"); Debug.Log("3. Use ForceTransportBinding → Force Then Start Host"); Debug.Log("4. Test on yougetsignal"); Debug.Log("==============================="); } } }