This commit is contained in:
2026-05-01 20:07:12 +07:00
parent 3226eab649
commit afd629cd53
13 changed files with 1028 additions and 1693 deletions

View File

@@ -11,7 +11,19 @@ namespace Hallucinate.UI
{
public class BasicSpawner : MonoBehaviour, INetworkRunnerCallbacks
{
public static BasicSpawner Instance { get; private set; }
private static BasicSpawner _instance;
public static BasicSpawner Instance
{
get
{
if (_instance == null)
{
_instance = UnityEngine.Object.FindFirstObjectByType<BasicSpawner>();
}
return _instance;
}
}
private NetworkRunner _runner;
public NetworkRunner Runner => _runner;
@@ -29,12 +41,15 @@ namespace Hallucinate.UI
private void Awake()
{
if (Instance != null && Instance != this)
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
_instance = this;
// Ensure this is a root object so DontDestroyOnLoad works correctly
transform.SetParent(null);
DontDestroyOnLoad(gameObject);
}
@@ -341,17 +356,10 @@ namespace Hallucinate.UI
_spawnedCharacters.Add(player, networkPlayerObject);
}
}
// Removed incorrect UI transition for Lobby/Menu scenes to allow LobbyController to manage its state.
// The original logic incorrectly called UIManager.OnBackToMenu() when entering the Lobby scene,
// causing the redirect to the Main Menu after creating a room.
// This block ensures that only the Main Scene triggers a specific UI transition (OnGameStarted).
// If other scenes like "Lobby" or "Menu" are loaded, no automatic transition is forced from here,
// letting scene-specific controllers (like LobbyController) manage their UI.
if (currentSceneName == "Main Scene")
{
UIManager.Instance?.OnGameStarted();
}
// Removed the problematic else-if block that would incorrectly call OnBackToMenu for "Lobby" or "Menu" scenes.
}