코드 경고 제거 및 미사용 코드 제거

This commit is contained in:
2026-02-16 22:38:51 +09:00
parent f73c660579
commit cc2487e7e4
32 changed files with 561 additions and 1572 deletions

View File

@@ -1,40 +0,0 @@
using UnityEngine;
using Unity.Netcode;
public class AutoHost : MonoBehaviour
{
[Header("Auto Host Settings")]
[SerializeField] private bool enableAutoHost = true;
[SerializeField] private bool onlyInEditor = true;
private void Start()
{
if (ShouldAutoStart())
{
if (NetworkManager.Singleton != null)
{
if (!NetworkManager.Singleton.IsServer && !NetworkManager.Singleton.IsClient)
{
NetworkManager.Singleton.StartHost();
Debug.Log("<color=yellow><b>[AutoHost]</b> Auto-host started</color>");
}
}
else
{
Debug.LogError("[AutoHost] NetworkManager not found!");
}
}
}
private bool ShouldAutoStart()
{
if (!enableAutoHost)
return false;
#if UNITY_EDITOR
return true;
#else
return !onlyInEditor;
#endif
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: f0ad96fafd5ac4f4db7e02424e132b89

View File

@@ -65,7 +65,6 @@ namespace Northbound
private BuildingHealthBar _healthBar;
private float _lastRegenTime;
private bool _isInitialized = false;
public override void OnNetworkSpawn()
{
@@ -172,8 +171,6 @@ namespace Northbound
FogOfWarSystem.Instance?.RegisterVisionProvider(this);
}
}
_isInitialized = true;
}
/// <summary>

View File

@@ -228,7 +228,7 @@ namespace Northbound.Editor
private static void AutoConfigureBuildingManager()
{
BuildingManager buildingManager = GameObject.FindObjectOfType<BuildingManager>();
BuildingManager buildingManager = GameObject.FindFirstObjectByType<BuildingManager>();
if (buildingManager == null)
{

View File

@@ -1,93 +0,0 @@
using UnityEngine;
using UnityEditor;
namespace Northbound.Editor
{
public class QuickNetworkSetupEditor
{
[MenuItem("Tools/Network/Quick Setup for IP Connection")]
public static void QuickSetup()
{
bool disableAutoHost = EditorUtility.DisplayDialog(
"Quick Network Setup",
"This will set up your scene for manual IP-based network connections.\n\n" +
"It will:\n" +
"- Create a NetworkConnectionHelper component\n" +
"- Disable AutoHost (to prevent auto-start)\n\n" +
"Do you want to disable AutoHost?",
"Yes, disable AutoHost",
"No, keep AutoHost"
);
CreateNetworkHelper();
if (disableAutoHost)
{
DisableAutoHost();
}
EditorUtility.DisplayDialog(
"Setup Complete",
"Quick network setup complete!\n\n" +
"Next steps:\n" +
"1. Open Window > Network > Connection Manager\n" +
"2. Or use the NetworkConnectionHelper in Inspector\n" +
"3. Start Host on one instance\n" +
"4. Start Client on other instances with the Host's IP",
"OK"
);
}
[MenuItem("Tools/Network/Create Connection Helper")]
public static void CreateNetworkHelper()
{
if (Object.FindObjectOfType<NetworkConnectionHelper>() == null)
{
GameObject helperObj = new GameObject("NetworkConnectionHelper");
helperObj.AddComponent<NetworkConnectionHelper>();
Selection.activeGameObject = helperObj;
Debug.Log("[QuickNetworkSetup] NetworkConnectionHelper created");
}
else
{
Debug.Log("[QuickNetworkSetup] NetworkConnectionHelper already exists");
}
}
[MenuItem("Tools/Network/Disable AutoHost")]
public static void DisableAutoHost()
{
AutoHost[] autoHosts = Object.FindObjectsByType<AutoHost>(FindObjectsSortMode.None);
if (autoHosts.Length > 0)
{
foreach (var autoHost in autoHosts)
{
autoHost.enabled = false;
}
Debug.Log($"[QuickNetworkSetup] Disabled {autoHosts.Length} AutoHost component(s)");
}
else
{
Debug.Log("[QuickNetworkSetup] No AutoHost components found");
}
}
[MenuItem("Tools/Network/Enable AutoHost")]
public static void EnableAutoHost()
{
AutoHost[] autoHosts = Object.FindObjectsByType<AutoHost>(FindObjectsSortMode.None);
if (autoHosts.Length > 0)
{
foreach (var autoHost in autoHosts)
{
autoHost.enabled = true;
}
Debug.Log($"[QuickNetworkSetup] Enabled {autoHosts.Length} AutoHost component(s)");
}
else
{
Debug.Log("[QuickNetworkSetup] No AutoHost components found");
}
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: d84f5c07a6e69614dad5178e0f994335

View File

@@ -54,7 +54,7 @@ namespace Northbound.Editor
}
}
BuildingManager buildingManager = GameObject.FindObjectOfType<BuildingManager>();
BuildingManager buildingManager = GameObject.FindFirstObjectByType<BuildingManager>();
Debug.Log($"<color=cyan>BuildingManager in Scene:</color>");
if (buildingManager == null)
{

View File

@@ -14,8 +14,6 @@ namespace Northbound
[Header("Common Settings")]
[Tooltip("맵 생성 시작 시 자동 생성")]
[SerializeField] private bool generateOnSpawn = true;
[Tooltip("생성된 오브젝트를 부모로 그룹화")]
[SerializeField] private bool groupUnderParent = true;
[Header("Map Boundaries")]
[Tooltip("X 범위 (-width/2 ~ +width/2)")]
@@ -155,7 +153,7 @@ namespace Northbound
private void FindImportantPositions()
{
Core core = FindObjectOfType<Core>();
Core core = FindFirstObjectByType<Core>();
if (core != null)
{
_corePosition = new Vector2(core.transform.position.x, core.transform.position.z);
@@ -165,7 +163,7 @@ namespace Northbound
_corePosition = Vector2.zero;
}
Resource[] resources = FindObjectsOfType<Resource>();
Resource[] resources = FindObjectsByType<Resource>(FindObjectsSortMode.InstanceID);
if (resources.Length > 0)
{
_initialResourcePosition = new Vector2(resources[0].transform.position.x, resources[0].transform.position.z);

View File

@@ -11,7 +11,6 @@ namespace Northbound
[Header("Auto Start")]
[SerializeField] private bool autoStartAsHost = false;
[SerializeField] private bool onlyInEditor = true;
private void Start()
{

View File

@@ -24,14 +24,14 @@ public class NetworkDebug : MonoBehaviour
}
// 3. NetworkConnectionHandler 확인
var connectionHandler = FindObjectOfType<NetworkConnectionHandler>();
var connectionHandler = FindFirstObjectByType<NetworkConnectionHandler>();
if (connectionHandler != null)
{
Debug.Log($"NetworkConnectionHandler: spawnPoints.Count={connectionHandler.spawnPoints.Count}, findAuto={connectionHandler.findSpawnPointsAutomatically}");
}
// 4. NetworkSpawnManager 확인
var spawnManager = FindObjectOfType<Northbound.NetworkSpawnManager>();
var spawnManager = FindFirstObjectByType<Northbound.NetworkSpawnManager>();
if (spawnManager != null)
{
Debug.Log($"NetworkSpawnManager: spawnPoints.Count={spawnManager.spawnPoints.Count}, findAuto={spawnManager.findSpawnPointsAutomatically}");

View File

@@ -1,244 +0,0 @@
using UnityEngine;
using Unity.Netcode;
namespace Northbound
{
/// <summary>
/// Quick test to verify NetworkManager is working and accessible
/// </summary>
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("<color=cyan>=== NETWORKMANAGER QUICK TEST ===</color>");
TestNetworkManagerExists();
TestPlayerPrefab();
TestTransport();
TestConnectionHandlers();
Debug.Log("<color=green>=== TEST COMPLETE ===</color>");
}
private void TestNetworkManagerExists()
{
Debug.Log("<color=yellow>[1/4] Testing NetworkManager Existence...</color>");
NetworkManager nm = NetworkManager.Singleton;
if (nm == null)
{
Debug.LogError("<color=red>✗ NetworkManager.Singleton is NULL!</color>");
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("<color=green>✓ NetworkManager found!</color>");
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("<color=yellow>[2/4] Testing Player Prefab...</color>");
NetworkManager nm = NetworkManager.Singleton;
if (nm == null)
{
Debug.LogError("<color=red>✗ Can't test - NetworkManager is null</color>");
return;
}
if (nm.NetworkConfig == null)
{
Debug.LogError("<color=red>✗ NetworkConfig is null!</color>");
return;
}
GameObject playerPrefab = nm.NetworkConfig.PlayerPrefab;
if (playerPrefab == null)
{
Debug.LogError("<color=red>✗ Player Prefab is NOT assigned!</color>");
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("<color=green>✓ Player Prefab assigned: " + playerPrefab.name + "</color>");
var networkObject = playerPrefab.GetComponent<Unity.Netcode.NetworkObject>();
if (networkObject == null)
{
Debug.LogWarning("<color=yellow>⚠ Player Prefab has NO NetworkObject!</color>");
Debug.LogWarning("→ Add NetworkObject component to Player Prefab");
}
else
{
Debug.Log("<color=green>✓ Player Prefab has NetworkObject</color>");
}
}
private void TestTransport()
{
Debug.Log("<color=yellow>[3/4] Testing Unity Transport...</color>");
NetworkManager nm = NetworkManager.Singleton;
if (nm == null)
{
Debug.LogError("<color=red>✗ Can't test - NetworkManager is null</color>");
return;
}
var transport = nm.GetComponent<Unity.Netcode.Transports.UTP.UnityTransport>();
if (transport == null)
{
Debug.LogError("<color=red>✗ Unity Transport not found on NetworkManager!</color>");
Debug.LogError("→ FIX: Add Unity Transport component to NetworkManager GameObject");
return;
}
Debug.Log("<color=green>✓ Unity Transport found!</color>");
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("<color=yellow>⚠ Transport Port is not set (0)!</color>");
Debug.LogWarning("→ FIX: Set Port to 40445 in Unity Transport component");
}
if (transport.ConnectionData.Address == "127.0.0.1")
{
Debug.LogError("<color=red>✗ Transport Address is 127.0.0.1!</color>");
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("<color=green>✓ Transport Address is 0.0.0.0 (accepts all connections)</color>");
}
}
private void TestConnectionHandlers()
{
Debug.Log("<color=yellow>[4/4] Testing Connection Handlers...</color>");
NetworkConnectionHandler handler = FindObjectOfType<NetworkConnectionHandler>();
if (handler == null)
{
Debug.LogWarning("<color=yellow>⚠ NetworkConnectionHandler not found!</color>");
Debug.LogWarning("→ Manual player spawning may not work");
Debug.LogWarning("→ FIX: Add NetworkConnectionHandler component to scene");
return;
}
Debug.Log("<color=green>✓ NetworkConnectionHandler found!</color>");
Debug.Log("→ Manual player spawning should work");
PlayerSpawnPoint[] spawnPoints = FindObjectsByType<PlayerSpawnPoint>(FindObjectsSortMode.None);
if (spawnPoints.Length > 0)
{
Debug.Log("<color=green>✓ Found " + spawnPoints.Length + " Player Spawn Point(s)</color>");
}
else
{
Debug.LogWarning("<color=yellow>⚠ No Player Spawn Points found!</color>");
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<Unity.Netcode.Transports.UTP.UnityTransport>();
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("===============================");
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 1d695616342b92d449295973fc4cda7e

View File

@@ -1,346 +0,0 @@
using UnityEngine;
using Unity.Netcode;
namespace Northbound
{
/// <summary>
/// Validates NetworkManager configuration before starting server
/// Checks for common issues that prevent server from starting
/// </summary>
public class NetworkManagerValidator : MonoBehaviour
{
[Header("Validation Settings")]
[SerializeField] private bool validateOnStart = true;
[SerializeField] private bool validateOnEnable = true;
[SerializeField] private bool showDetailedLogs = true;
[Header("Auto-Fix")]
[SerializeField] private bool autoFixIfPossible = true;
private NetworkManager _networkManager;
private bool _hasValidated = false;
private void Awake()
{
StartCoroutine(InitializeDelayed());
}
private System.Collections.IEnumerator InitializeDelayed()
{
Debug.Log("[NetworkValidator] Waiting for NetworkManager to initialize...");
int attempts = 0;
while (_networkManager == null && attempts < 50)
{
_networkManager = NetworkManager.Singleton;
if (_networkManager == null)
{
yield return new WaitForSeconds(0.1f);
attempts++;
}
}
if (_networkManager == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ CRITICAL: NetworkManager not found after 50 attempts!</color>");
Debug.LogError("[NetworkValidator] Ensure NetworkManager is in scene and has 'NetworkManager' component");
yield break;
}
Debug.Log("[NetworkValidator] NetworkManager found!");
if (validateOnAwake)
{
yield return new WaitForSeconds(0.5f);
ValidateConfiguration();
}
}
private void Start()
{
if (validateOnStart && !_hasValidated)
{
ValidateConfiguration();
}
}
private void OnEnable()
{
if (validateOnEnable && !_hasValidated)
{
ValidateConfiguration();
}
}
[ContextMenu("Validate NetworkManager Configuration")]
public void ValidateConfiguration()
{
Debug.Log("<color=yellow>=== NETWORKMANAGER VALIDATION ===</color>");
if (_networkManager == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ NetworkManager is NULL!</color>");
Debug.LogError("[NetworkValidator] Cannot validate configuration");
return;
}
_hasValidated = true;
bool allValid = true;
allValid &= CheckPlayerPrefab();
allValid &= CheckNetworkConfig();
allValid &= CheckTransport();
allValid &= CheckRequiredComponents();
Debug.Log("");
if (allValid)
{
Debug.Log("<color=green>[NetworkValidator] ✅ ALL CHECKS PASSED - NetworkManager is ready!</color>");
Debug.Log("[NetworkValidator] Server should start successfully");
}
else
{
Debug.LogError("<color=red>[NetworkValidator] ❌ VALIDATION FAILED - Server may NOT start!</color>");
Debug.LogError("[NetworkValidator] Please fix the issues above");
}
Debug.Log("=================================");
}
private bool CheckPlayerPrefab()
{
Debug.Log("<color=cyan>[NetworkValidator] 1. Checking Player Prefab...</color>");
if (_networkManager.NetworkConfig == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ NetworkConfig is NULL!</color>");
return false;
}
GameObject playerPrefab = _networkManager.NetworkConfig.PlayerPrefab;
if (playerPrefab == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ Player Prefab is NOT assigned!</color>");
Debug.LogError("<color=red>[NetworkValidator] This is the #1 cause of servers not starting!</color>");
Debug.LogError("[NetworkValidator] FIX:");
Debug.LogError("1. Select NetworkManager in scene");
Debug.LogError("2. Inspector → Network Config → Player Prefab");
Debug.LogError("3. Drag your Player Prefab from Project window");
Debug.LogError("4. Assign to Player Prefab field");
return false;
}
Debug.Log("<color=green>[NetworkValidator] ✅ Player Prefab assigned: " + playerPrefab.name + "</color>");
NetworkObject networkObject = playerPrefab.GetComponent<NetworkObject>();
if (networkObject == null)
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ Player Prefab has NO NetworkObject!</color>");
Debug.LogWarning("[NetworkValidator] FIX: Add NetworkObject component to Player Prefab");
return false;
}
Debug.Log("<color=green>[NetworkValidator] ✅ Player Prefab has NetworkObject</color>");
return true;
}
private bool CheckNetworkConfig()
{
Debug.Log("<color=cyan>[NetworkValidator] 2. Checking Network Config...</color>");
if (_networkManager.NetworkConfig == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ NetworkConfig is NULL!</color>");
return false;
}
bool configValid = true;
bool connectionApproval = _networkManager.NetworkConfig.ConnectionApproval;
if (connectionApproval)
{
Debug.Log("<color=green>[NetworkValidator] ✅ Connection Approval: ENABLED</color>");
}
else
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ Connection Approval: DISABLED</color>");
Debug.LogWarning("[NetworkValidator] All connections will be auto-approved");
}
bool sceneManagement = _networkManager.NetworkConfig.EnableSceneManagement;
if (sceneManagement)
{
Debug.Log("<color=green>[NetworkValidator] ✅ Scene Management: ENABLED</color>");
}
else
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ Scene Management: DISABLED</color>");
}
float clientBuffer = _networkManager.NetworkConfig.ClientConnectionBufferTimeout;
Debug.Log("[NetworkValidator] Client Connection Buffer: " + clientBuffer + "s");
return configValid;
}
private bool CheckTransport()
{
Debug.Log("<color=cyan>[NetworkValidator] 3. Checking Transport...</color>");
var transport = _networkManager.GetComponent<Unity.Netcode.Transports.UTP.UnityTransport>();
if (transport == null)
{
Debug.LogError("<color=red>[NetworkValidator] ❌ UnityTransport not found!</color>");
Debug.LogError("[NetworkValidator] FIX: Add Unity Transport component to NetworkManager");
return false;
}
Debug.Log("<color=green>[NetworkValidator] ✅ Unity Transport exists</color>");
ushort port = transport.ConnectionData.Port;
Debug.Log("[NetworkValidator] Transport Port: " + port);
if (port <= 0)
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ Transport Port is not set (0)</color>");
Debug.LogWarning("[NetworkValidator] FIX: Set port to 40445 in Unity Transport component");
return false;
}
string address = transport.ConnectionData.Address;
Debug.Log("[NetworkValidator] Transport Address: " + address);
if (address == "127.0.0.1")
{
Debug.LogError("<color=red>[NetworkValidator] ❌ Transport Address is 127.0.0.1!</color>");
Debug.LogError("<color=red>[NetworkValidator] This blocks ALL remote connections!</color>");
Debug.LogError("[NetworkValidator] FIX: Set to 0.0.0.0");
return false;
}
if (address == "0.0.0.0")
{
Debug.Log("<color=green>[NetworkValidator] ✅ Transport Address: 0.0.0.0 (accepts all connections)</color>");
}
return true;
}
private bool CheckRequiredComponents()
{
Debug.Log("<color=cyan>[NetworkValidator] 4. Checking Required Components...</color>");
bool allPresent = true;
NetworkConnectionHandler connectionHandler = FindObjectOfType<NetworkConnectionHandler>();
if (connectionHandler != null)
{
Debug.Log("<color=green>[NetworkValidator] ✅ NetworkConnectionHandler found</color>");
}
else
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ NetworkConnectionHandler NOT found</color>");
Debug.LogWarning("[NetworkValidator] FIX: Add NetworkConnectionHandler to scene");
Debug.LogWarning("[NetworkValidator] Required for manual player spawning");
}
PlayerSpawnPoint[] spawnPoints = FindObjectsByType<PlayerSpawnPoint>(FindObjectsSortMode.None);
if (spawnPoints.Length > 0)
{
Debug.Log("<color=green>[NetworkValidator] ✅ Found " + spawnPoints.Length + " Player Spawn Point(s)</color>");
}
else
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ No Player Spawn Points found</color>");
Debug.LogWarning("[NetworkValidator] FIX: Add PlayerSpawnPoint component to empty GameObject(s)");
}
AutoHost autoHost = FindObjectOfType<AutoHost>();
if (autoHost != null && autoHost.enabled)
{
Debug.LogWarning("<color=yellow>[NetworkValidator] ⚠ AutoHost is enabled!</color>");
Debug.LogWarning("[NetworkValidator] This might interfere with manual host startup");
Debug.LogWarning("[NetworkValidator] Consider disabling AutoHost");
}
return allPresent;
}
[ContextMenu("Generate Fix Report")]
public void GenerateFixReport()
{
Debug.Log("=== NETWORKMANAGER FIX REPORT ===");
Debug.Log("");
Debug.Log("PROBLEM: PortListenerTest works, but Unity Netcode doesn't");
Debug.Log("");
Debug.Log("MOST LIKELY CAUSE:");
Debug.LogError("1. ❌ Player Prefab is NOT assigned (90% probability)");
Debug.LogWarning("2. ⚠ NetworkManager has initialization order issue");
Debug.LogWarning("3. ⚠ Transport not configured correctly");
Debug.LogWarning("4. ⚠ AutoHost interfering");
Debug.Log("");
Debug.Log("QUICK FIX:");
Debug.Log("1. Select NetworkManager in scene");
Debug.Log("2. Inspector → Network Config → Player Prefab");
Debug.Log("3. Drag your Player Prefab from Project window");
Debug.Log("4. Drop into Player Prefab field");
Debug.Log("5. Save scene");
Debug.Log("6. Start Host");
Debug.Log("7. Test on yougetsignal IMMEDIATELY");
Debug.Log("");
Debug.Log("COMPLETE FIX:");
Debug.Log("1. Right-click this component → 'Validate NetworkManager Configuration'");
Debug.Log("2. Fix any errors shown");
Debug.Log("3. Add ForceTransportBinding");
Debug.Log("4. Right-click → 'Force Then Start Host'");
Debug.Log("5. Add ContinuousPortMonitor");
Debug.Log("6. Right-click → 'Start Port Monitoring'");
Debug.Log("7. Watch Console for port status");
Debug.Log("=================================");
}
[ContextMenu("Check If Server Can Start")]
public void CheckIfServerCanStart()
{
Debug.Log("=== CAN SERVER START? ===");
bool canStart = true;
if (_networkManager == null)
{
Debug.LogError("❌ NO - NetworkManager is NULL");
canStart = false;
}
else
{
if (_networkManager.NetworkConfig?.PlayerPrefab == null)
{
Debug.LogError("❌ NO - Player Prefab NOT assigned");
canStart = false;
}
if (_networkManager.GetComponent<Unity.Netcode.Transports.UTP.UnityTransport>() == null)
{
Debug.LogError("❌ NO - UnityTransport NOT found");
canStart = false;
}
}
if (canStart)
{
Debug.Log("<color=green>✅ YES - Server should be able to start</color>");
Debug.Log("If port still closed after starting:");
Debug.Log("1. Check Console for errors");
Debug.Log("2. Verify Port Forwarding is working");
Debug.Log("3. Verify Firewall is allowing port");
}
Debug.Log("========================");
}
private bool validateOnAwake = true;
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 926d1f00e8a21ab44a9f4cc1bf0028bd

View File

@@ -15,7 +15,6 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
[Header("Health Settings")]
[SerializeField] private int maxHealth = 100;
[SerializeField] private bool showHealthBar = true;
[Header("Visual Effects")]
[SerializeField] private GameObject damageEffectPrefab;

View File

@@ -1,237 +0,0 @@
using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using System.Net.Sockets;
using System.Net;
namespace Northbound
{
/// <summary>
/// Completely restarts network to fix stuck/closed port issues
/// </summary>
public class NetworkResetAndRestart : MonoBehaviour
{
[Header("Reset Settings")]
[SerializeField] private bool autoResetOnStart = false;
[SerializeField] private ushort targetPort = 40445;
private NetworkManager _networkManager;
private UnityTransport _transport;
private void Start()
{
if (autoResetOnStart)
{
StartCoroutine(DoResetAndRestart());
}
}
[ContextMenu("Reset Network and Restart Host")]
public void ExecuteResetAndRestart()
{
StartCoroutine(DoResetAndRestart());
}
private System.Collections.IEnumerator DoResetAndRestart()
{
Debug.Log("<color=yellow>=== NETWORK RESET AND RESTART ===</color>");
// Step 1: Get references
_networkManager = NetworkManager.Singleton;
if (_networkManager == null)
{
Debug.LogError("<color=red>[NetworkReset] NetworkManager not found!</color>");
yield break;
}
_transport = _networkManager.GetComponent<UnityTransport>();
if (_transport == null)
{
Debug.LogError("<color=red>[NetworkReset] UnityTransport not found!</color>");
yield break;
}
// Step 2: Log current state
LogCurrentState();
// Step 3: Shutdown if running
if (_networkManager.IsServer || _networkManager.IsClient)
{
Debug.Log("<color=yellow>[NetworkReset] Shutting down current network...</color>");
_networkManager.Shutdown();
// Wait for complete shutdown
float startTime = Time.time;
while ((_networkManager.IsServer || _networkManager.IsClient) && Time.time - startTime < 10f)
{
yield return new WaitForSeconds(0.1f);
}
Debug.Log("<color=green>[NetworkReset] ✓ Network shutdown complete</color>");
}
yield return new WaitForSeconds(1f);
// Step 4: Force port release
ForcePortRelease();
yield return new WaitForSeconds(1f);
// Step 5: Reconfigure transport
Debug.Log("<color=cyan>[NetworkReset] Reconfiguring transport...</color>");
_transport.SetConnectionData(
"0.0.0.0", // Listen on all interfaces
targetPort, // Port 40445
"0.0.0.0" // Server listen on all interfaces
);
Debug.Log("<color=green>[NetworkReset] ✓ Transport configured to 0.0.0.0:" + targetPort + "</color>");
Debug.Log("<color=green>[NetworkReset] ✓ Server will accept connections from ANY IP</color>");
yield return new WaitForSeconds(0.5f);
// Step 6: Start host
Debug.Log("<color=cyan>[NetworkReset] Starting fresh host...</color>");
_networkManager.StartHost();
// Wait for host to start
float hostStartTime = Time.time;
while (!_networkManager.IsServer && Time.time - hostStartTime < 10f)
{
yield return new WaitForSeconds(0.2f);
}
if (_networkManager.IsServer)
{
Debug.Log("<color=green>[NetworkReset] ✓ Host started successfully!</color>");
// Verify port is actually listening
yield return new WaitForSeconds(1f);
VerifyPortListening();
}
else
{
Debug.LogError("<color=red>[NetworkReset] ✗ Failed to start host!</color>");
}
Debug.Log("<color=green>=== RESET AND RESTART COMPLETE ===</color>");
}
private void LogCurrentState()
{
Debug.Log("<color=cyan>[NetworkReset] Current Network State:</color>");
Debug.Log(" IsServer: " + _networkManager.IsServer);
Debug.Log(" IsClient: " + _networkManager.IsClient);
Debug.Log(" IsHost: " + _networkManager.IsHost);
Debug.Log(" IsConnectedClient: " + _networkManager.IsConnectedClient);
Debug.Log(" LocalClientId: " + _networkManager.LocalClientId);
Debug.Log(" ConnectedClients: " + _networkManager.ConnectedClients.Count);
if (_transport != null)
{
Debug.Log(" Transport.Port: " + _transport.ConnectionData.Port);
Debug.Log(" Transport.Address: " + _transport.ConnectionData.Address);
}
}
private void ForcePortRelease()
{
Debug.Log("<color=cyan>[NetworkReset] Forcing port release...</color>");
try
{
// Try to bind and release port to ensure it's freed
TcpListener testListener = new TcpListener(IPAddress.Any, targetPort);
testListener.Start();
testListener.Stop();
Debug.Log("<color=green>[NetworkReset] ✓ Port " + targetPort + " is released</color>");
}
catch (System.Exception e)
{
Debug.LogWarning("<color=yellow>[NetworkReset] ⚠ Could not bind port for release: " + e.Message + "</color>");
Debug.LogWarning("[NetworkReset] This is normal if port is in use");
}
}
private void VerifyPortListening()
{
Debug.Log("<color=cyan>[NetworkReset] Verifying port is listening...</color>");
try
{
using (TcpClient client = new TcpClient("127.0.0.1", targetPort))
{
Debug.Log("<color=green>[NetworkReset] ✓ Successfully connected to localhost:" + targetPort + "</color>");
Debug.Log("<color=green>[NetworkReset] ✓ Unity IS listening on port</color>");
Debug.Log("<color=green>[NetworkReset] ✓ Port should now be accessible on yougetsignal</color>");
Debug.Log("");
Debug.Log("<color=green>[NetworkReset] ✓ TEST ON YOUGETSIGNAL NOW!</color>");
}
}
catch (System.Exception e)
{
Debug.LogWarning("<color=yellow>[NetworkReset] ⚠ Could not connect to localhost:" + targetPort + "</color>");
Debug.LogWarning("[NetworkReset] Error: " + e.Message);
Debug.LogWarning("[NetworkReset] This might mean server didn't actually start");
}
}
[ContextMenu("Check Current Network Status")]
public void CheckStatus()
{
_networkManager = NetworkManager.Singleton;
if (_networkManager == null)
{
Debug.LogError("NetworkManager not found");
return;
}
Debug.Log("=== NETWORK STATUS ===");
Debug.Log("IsServer: " + _networkManager.IsServer);
Debug.Log("IsClient: " + _networkManager.IsClient);
Debug.Log("IsHost: " + _networkManager.IsHost);
Debug.Log("IsConnectedClient: " + _networkManager.IsConnectedClient);
Debug.Log("LocalClientId: " + _networkManager.LocalClientId);
Debug.Log("ConnectedClients: " + _networkManager.ConnectedClients.Count);
foreach (var client in _networkManager.ConnectedClients)
{
Debug.Log(" Client " + client.Key + ": " +
(client.Value.PlayerObject != null ? "Has Player" : "No Player"));
}
Debug.Log("===================");
}
[ContextMenu("Generate Instructions")]
public void GenerateInstructions()
{
Debug.Log("=== NETWORK RESET INSTRUCTIONS ===");
Debug.Log("");
Debug.Log("PROBLEM:");
Debug.Log("- Port stays closed even though config is correct");
Debug.Log("- Server reports running but port not accessible");
Debug.Log("");
Debug.Log("SOLUTION: Complete network reset");
Debug.Log("");
Debug.Log("STEPS:");
Debug.Log("1. Add NetworkResetAndRestart to scene");
Debug.Log("2. Right-click → 'Reset Network and Restart Host'");
Debug.Log("3. Wait for '✓ Host started successfully'");
Debug.Log("4. Test on yougetsignal IMMEDIATELY");
Debug.Log("");
Debug.Log("WHAT IT DOES:");
Debug.Log("1. Shuts down any current network");
Debug.Log("2. Forces port release");
Debug.Log("3. Reconfigures transport to 0.0.0.0");
Debug.Log("4. Starts fresh host");
Debug.Log("5. Verifies port is actually listening");
Debug.Log("");
Debug.Log("EXPECTED RESULT:");
Debug.Log("✓ Port 40445 shows OPEN on yougetsignal");
Debug.Log("✓ Teammates can connect");
Debug.Log("===============================");
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: d15e6615b07f55843a759c775a08bc89

View File

@@ -1,245 +0,0 @@
using UnityEngine;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using Unity.Netcode;
// Removed System.Diagnostics to fix Debug.Log ambiguity
namespace Northbound
{
/// <summary>
/// Runs PortListenerTest method simultaneously with Unity Netcode
/// Uses exact same TcpListener method that works
/// </summary>
public class PortListenerTestSimultaneous : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private ushort testPort = 40445;
[SerializeField] private bool autoStartOnEnable = false;
private TcpListener _listener;
private Thread _listenerThread;
private volatile bool _isRunning = false;
private volatile bool _hasConnection = false;
private NetworkManager _networkManager;
private void OnEnable()
{
if (autoStartOnEnable)
{
StartTest();
}
}
private void Start()
{
_networkManager = NetworkManager.Singleton;
}
[ContextMenu("Start Test Only")]
public void StartTest()
{
UnityEngine.Debug.Log("<color=magenta>=== PORT LISTENER TEST (SIMULTANEOUS) ===</color>");
UnityEngine.Debug.Log("Using EXACT same method as PortListenerTest");
UnityEngine.Debug.Log("Method: TcpListener(IPAddress.Any, " + testPort + ")");
UnityEngine.Debug.Log("This PROVES port CAN be bound");
_isRunning = true;
_listenerThread = new Thread(ListenerThread);
_listenerThread.IsBackground = true;
_listenerThread.Start();
}
[ContextMenu("Start Test + Unity Netcode")]
public void StartTestAndUnity()
{
UnityEngine.Debug.Log("<color=magenta>=== STARTING TEST + UNITY NETCODE ===</color>");
StartTest();
StartCoroutine(StartUnityDelayed());
}
private System.Collections.IEnumerator StartUnityDelayed()
{
UnityEngine.Debug.Log("Waiting 3 seconds before starting Unity...");
yield return new WaitForSeconds(3f);
UnityEngine.Debug.Log("Starting Unity Netcode...");
if (_networkManager == null)
{
UnityEngine.Debug.LogError("NetworkManager not found!");
yield break;
}
if (_networkManager.IsServer || _networkManager.IsClient)
{
UnityEngine.Debug.Log("Unity already running, shutting down first...");
_networkManager.Shutdown();
yield return new WaitForSeconds(2f);
}
_networkManager.StartHost();
float startTime = Time.time;
while (!_networkManager.IsServer && Time.time - startTime < 10f)
{
UnityEngine.Debug.Log("Waiting for Unity to start...");
yield return new WaitForSeconds(0.5f);
}
if (_networkManager.IsServer)
{
UnityEngine.Debug.Log("<color=green>Unity Netcode started successfully!</color>");
UnityEngine.Debug.Log("Now BOTH listeners are running:");
UnityEngine.Debug.Log(" 1. TcpListener (proven method)");
UnityEngine.Debug.Log(" 2. Unity Netcode");
}
else
{
UnityEngine.Debug.LogError("Unity Netcode failed to start!");
}
}
private void ListenerThread()
{
try
{
_listener = new TcpListener(IPAddress.Any, testPort);
_listener.Start();
UnityEngine.Debug.Log("<color=green>Successfully bound to 0.0.0.0:" + testPort + "</color>");
UnityEngine.Debug.Log("PROVED: Port " + testPort + " CAN be bound");
UnityEngine.Debug.Log("PROVED: OS allows binding");
UnityEngine.Debug.Log("PROVED: Firewall allows binding");
while (_isRunning)
{
if (_listener.Pending())
{
try
{
TcpClient client = _listener.AcceptTcpClient();
IPEndPoint endPoint = (IPEndPoint)client.Client.RemoteEndPoint;
_hasConnection = true;
UnityEngine.Debug.Log("<color=green>Connection received from " + endPoint.Address + ":" + endPoint.Port + "</color>");
UnityEngine.Debug.Log("PROVES: Port IS OPEN and working");
UnityEngine.Debug.Log("PROVES: Port forwarding IS working");
UnityEngine.Debug.Log("PROVES: Test listener method WORKS");
Thread.Sleep(100);
client.Close();
}
catch (System.Exception e)
{
UnityEngine.Debug.LogWarning("Error accepting: " + e.Message);
}
}
else
{
Thread.Sleep(100);
}
}
_listener.Stop();
}
catch (System.Exception e)
{
_isRunning = false;
UnityEngine.Debug.LogError("<color=red>Failed to bind port " + testPort + "</color>");
UnityEngine.Debug.LogError("Error: " + e.Message);
}
}
[ContextMenu("Stop Test")]
public void StopTest()
{
UnityEngine.Debug.Log("Stopping test listener...");
_isRunning = false;
if (_listener != null)
{
_listener.Stop();
}
if (_listenerThread != null && _listenerThread.IsAlive)
{
_listenerThread.Join(1000);
}
_hasConnection = false;
}
[ContextMenu("Check Status")]
public void CheckStatus()
{
UnityEngine.Debug.Log("=== SIMULTANEOUS TEST STATUS ===");
UnityEngine.Debug.Log("Test Listener Running: " + _isRunning);
UnityEngine.Debug.Log("Has Connection: " + _hasConnection);
if (_networkManager != null)
{
UnityEngine.Debug.Log("Unity IsServer: " + _networkManager.IsServer);
UnityEngine.Debug.Log("Unity IsClient: " + _networkManager.IsClient);
UnityEngine.Debug.Log("Unity IsHost: " + _networkManager.IsHost);
}
if (_hasConnection)
{
UnityEngine.Debug.Log("<color=green>Port IS OPEN - Test listener works!</color>");
}
UnityEngine.Debug.Log("===================================");
}
[ContextMenu("Explanation")]
public void ShowExplanation()
{
UnityEngine.Debug.Log("=== EXPLANATION ===");
UnityEngine.Debug.Log("");
UnityEngine.Debug.Log("WHAT THIS DOES:");
UnityEngine.Debug.Log("Uses EXACT same method as PortListenerTest:");
UnityEngine.Debug.Log(" new TcpListener(IPAddress.Any, 40445)");
UnityEngine.Debug.Log(" listener.Start()");
UnityEngine.Debug.Log("");
UnityEngine.Debug.Log("WHY PORTLISTENERTEST WORKS:");
UnityEngine.Debug.Log("✓ Successfully binds to port");
UnityEngine.Debug.Log("✓ Port is OPEN on yougetsignal");
UnityEngine.Debug.Log("✓ OS allows binding");
UnityEngine.Debug.Log("✓ Firewall allows binding");
UnityEngine.Debug.Log("");
UnityEngine.Debug.Log("WHY WE RUN IT WITH UNITY:");
UnityEngine.Debug.Log("→ To see if they conflict");
UnityEngine.Debug.Log("→ To see if Unity Netcode binds");
UnityEngine.Debug.Log("→ To identify what's different");
UnityEngine.Debug.Log("");
UnityEngine.Debug.Log("EXPECTED RESULTS:");
UnityEngine.Debug.Log("If test listener receives connection:");
UnityEngine.Debug.Log(" → Port IS OPEN");
UnityEngine.Debug.Log(" → Test method WORKS");
UnityEngine.Debug.Log(" → Something is wrong with Unity Netcode");
UnityEngine.Debug.Log("");
UnityEngine.Debug.Log("HOW TO USE:");
UnityEngine.Debug.Log("1. Add to scene");
UnityEngine.Debug.Log("2. Right-click 'Start Test + Unity Netcode'");
UnityEngine.Debug.Log("3. Wait 3 seconds");
UnityEngine.Debug.Log("4. See if both start");
UnityEngine.Debug.Log("5. Test on yougetsignal");
UnityEngine.Debug.Log("=============================");
}
private void OnDestroy()
{
StopTest();
}
private void OnDisable()
{
StopTest();
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: ba79d51f450e07d439690667a6535133

View File

@@ -1,54 +0,0 @@
using UnityEngine;
namespace Northbound
{
public class QuickNetworkSetup : MonoBehaviour
{
[Header("Quick Setup Options")]
[Tooltip("Create a NetworkConnectionHelper component")]
[SerializeField] private bool createConnectionHelper = true;
[Tooltip("Disable AutoHost to prevent auto-start")]
[SerializeField] private bool disableAutoHost = true;
private void Awake()
{
SetupScene();
}
private void SetupScene()
{
if (createConnectionHelper)
{
CreateConnectionHelper();
}
if (disableAutoHost)
{
DisableAutoHost();
}
Destroy(this);
}
private void CreateConnectionHelper()
{
if (FindObjectOfType<NetworkConnectionHelper>() == null)
{
GameObject helperObj = new GameObject("NetworkConnectionHelper");
helperObj.AddComponent<NetworkConnectionHelper>();
Debug.Log("[QuickNetworkSetup] NetworkConnectionHelper created");
}
}
private void DisableAutoHost()
{
AutoHost[] autoHosts = FindObjectsByType<AutoHost>(FindObjectsSortMode.None);
foreach (var autoHost in autoHosts)
{
autoHost.enabled = false;
Debug.Log("[QuickNetworkSetup] AutoHost disabled");
}
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 572b945beced27f418a84bba613ff5b9

View File

@@ -370,7 +370,6 @@ namespace Northbound
}
var spawnedObjects = NetworkManager.Singleton.SpawnManager.SpawnedObjects;
int objectsChecked = 0;
int workersFound = 0;
foreach (var kvp in spawnedObjects)

View File

@@ -9,8 +9,6 @@ namespace Northbound
[Header("Input Actions")]
[SerializeField] private InputActionReference startAsClientAction;
private bool _isClientStarted = false;
private void Start()
{
if (startAsClientAction != null && startAsClientAction.action != null)
@@ -41,8 +39,6 @@ namespace Northbound
return;
}
_isClientStarted = true;
Debug.Log("[ShortcutNetworkStarter] 클라이언트 모드로 시작합니다...");
NetworkManager.Singleton.StartClient();
}

View File

@@ -1,123 +0,0 @@
using UnityEngine;
using Unity.Netcode;
namespace Northbound
{
/// <summary>
/// Simple monitor for network restarts
/// Detects if Unity Netcode is shutting down repeatedly
/// </summary>
public class SimpleNetworkMonitor : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private bool enableOnStart = true;
[SerializeField] private float checkInterval = 2f;
private NetworkManager _networkManager;
private float _lastCheckTime;
private int _serverStopCount = 0;
private int _serverStartCount = 0;
private float _lastServerStartTime = 0f;
private int _eventsLogged = 0;
private void Start()
{
if (enableOnStart)
{
_networkManager = NetworkManager.Singleton;
}
}
private void Update()
{
if (_networkManager == null)
{
_networkManager = NetworkManager.Singleton;
}
if (Time.time - _lastCheckTime >= checkInterval)
{
_lastCheckTime = Time.time;
CheckNetworkStatus();
}
}
private void CheckNetworkStatus()
{
if (_networkManager == null)
{
return;
}
bool isServer = _networkManager.IsServer;
bool isClient = _networkManager.IsClient;
bool isHost = _networkManager.IsHost;
if (isServer && !isClient && _eventsLogged < 3)
{
_serverStartCount++;
_lastServerStartTime = Time.time;
_eventsLogged++;
}
if (!isServer && !isClient && _lastServerStartTime > 0f && _eventsLogged < 50)
{
float uptime = Time.time - _lastServerStartTime;
_serverStopCount++;
_eventsLogged++;
if (_serverStopCount >=3)
{
}
}
if (isServer && _serverStartCount > 0)
{
if (_eventsLogged % 10 ==0)
{
float uptime = Time.time - _lastServerStartTime;
_eventsLogged++;
}
}
if (!isServer && !isClient && _lastServerStartTime > 0f && _eventsLogged < 50)
{
float uptime = Time.time - _lastServerStartTime;
_serverStopCount++;
Debug.LogWarning("[SimpleMonitor] Server stopped (Count: " + _serverStopCount + ", Uptime: " + uptime.ToString("F1") + "s)");
_eventsLogged++;
if (_serverStopCount >= 3)
{
Debug.LogError("[SimpleMonitor] SERVER STOPPED " + _serverStopCount + " TIMES!");
Debug.LogError("[SimpleMonitor] This is why port closes!");
Debug.LogError("[SimpleMonitor] Something is calling NetworkManager.Shutdown()");
}
}
if (isServer && _serverStartCount > 0)
{
if (_eventsLogged % 10 == 0)
{
float uptime = Time.time - _lastServerStartTime;
Debug.Log("[SimpleMonitor] Server uptime: " + uptime.ToString("F1") + "s");
_eventsLogged++;
}
}
}
[ContextMenu("Reset Counters")]
public void ResetCounters()
{
_serverStopCount = 0;
_serverStartCount = 0;
_lastServerStartTime = 0f;
_eventsLogged = 0;
}
[ContextMenu("Show Stats")]
public void ShowStats()
{
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 977685b2792b7684dbc782d410338a51

View File

@@ -108,7 +108,7 @@ namespace Northbound
private void FindCore()
{
Core[] cores = FindObjectsOfType<Core>();
Core[] cores = FindObjectsByType<Core>(FindObjectsSortMode.InstanceID);
if (cores.Length > 0)
{
_core = cores[0];