Petition-to-the-Gods-V3/Assets/Scripts/SceneController.cs
2025-11-18 14:54:11 +08:00

64 lines
1.3 KiB
C#

using UnityEngine;
using UnityEngine.SceneManagement;
using Mirror;
public class SceneController : MonoBehaviour
{
[Header("場景名稱設置")]
public string initSceneName = "InitScene";
public string serverHomeSceneName = "ServerHomeScene";
public string clientHomeSceneName = "ClientHomeScene";
private static SceneController instance;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
#region ServerScene
public static void LoadServerHomeScene()
{
if (instance != null)
{
Debug.Log("Switch to Server Home");
SceneManager.LoadScene(instance.serverHomeSceneName);
}
}
#endregion
#region ClientScene
public static void LoadClientHomeScene()
{
if (instance != null)
{
Debug.Log("Switch to Client Home");
SceneManager.LoadScene(instance.clientHomeSceneName);
}
}
#endregion
}