51 lines
1016 B
C#
51 lines
1016 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using TMPro;
|
|
|
|
public class ServerHomeWaittingSceneController : MonoBehaviour
|
|
{
|
|
public static ServerHomeWaittingSceneController Instance;
|
|
|
|
[Header("UI 元件")]
|
|
public TMP_Text waitingText;
|
|
|
|
private bool clientConnected = false;
|
|
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
SetupHomeScene();
|
|
}
|
|
|
|
void SetupHomeScene()
|
|
{
|
|
if (waitingText != null)
|
|
{
|
|
waitingText.text = "等待您的客戶加入…";
|
|
}
|
|
}
|
|
|
|
public void OnClientConnected()
|
|
{
|
|
if (!clientConnected)
|
|
{
|
|
clientConnected = true;
|
|
Debug.Log("客戶端已連接,準備跳轉場景");
|
|
|
|
|
|
StartCoroutine(LoadIntroScene());
|
|
}
|
|
}
|
|
|
|
IEnumerator LoadIntroScene()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
SceneManager.LoadScene("ServerIntroScene");
|
|
}
|
|
} |