This commit is contained in:
2026-05-01 21:58:20 +07:00
parent 07fb48353c
commit 709ed4069d
26 changed files with 599 additions and 1008 deletions

View File

@@ -72,8 +72,13 @@ namespace Hallucinate.UI
await _runner.Shutdown();
}
Debug.Log("[BasicSpawner] Destroying existing runner component.");
Destroy(_runner);
// Check if it still exists (Unity pseudo-null check)
if (_runner != null)
{
// Only log if it's actually a valid object to destroy
// If it's already marked for destruction, Unity == null will be true soon
Destroy(_runner);
}
_runner = null;
await Task.Yield();
@@ -84,6 +89,8 @@ namespace Hallucinate.UI
}
}
if (this == null) return; // BasicSpawner itself might be destroyed
Debug.Log("[BasicSpawner] Creating new NetworkRunner component.");
_runner = gameObject.AddComponent<NetworkRunner>();
_runner.ProvideInput = true;
@@ -118,7 +125,12 @@ namespace Hallucinate.UI
public async Task<bool> StartHost(string sessionName, string displayName, string password = null)
{
if (_isStarting) return false;
// Wait for any existing startup process (like StartLobby) to finish
while (_isStarting)
{
await Task.Yield();
}
_isStarting = true;
try