![](/img/trans.png)
[英]Sending a message about connecting to the master client room on unity photon
[英]Error when leaving the master's room from the room Photon
我將房間存在的計時器設置為房間的屬性。 主玩家一離開房間,就會觸發異常:Operation setProperties (252) not call because client is not connected or not ready, client state: Leaving。 此錯誤不影響操作,其他玩家退出時不會出現此錯誤。 我該如何處理這個異常? 它只是打擾眼睛。
private void Update()
{
_currentPlayersCountText.text = PhotonNetwork.PlayerList.Length.ToString();
if (PhotonNetwork.IsMasterClient)
{
if (PhotonNetwork.PlayerList.Length >= 5)
{
_startGameButton.GetComponent<Button>().enabled = true;
}
else
{
_startGameButton.GetComponent<Button>().enabled = false;
}
Hashtable ht = PhotonNetwork.CurrentRoom.CustomProperties;
ht.Remove("timer");
ht.Add("timer", _roomTimer.timeRemaining);
PhotonNetwork.CurrentRoom.SetCustomProperties(ht);
}
if (_roomTimer.timeRemaining <= 110)
{
LeaveRoom();
}
}
這是最有可能導致此錯誤的代碼。
你可以試試
public void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
}
public override void OnLeftRoom()
{
StartCoroutine(WaitToLeave());
}
IEnumerator WaitToLeave()
{
while(PhotonNetwork.InRoom)
yield return null;
SceneManager.LoadScene(0);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.