简体   繁体   English

从房间光子离开主人房间时出错

[英]Error when leaving the master's room from the room Photon

I set the timer of the existence of the room as the properties of the room.我将房间存在的计时器设置为房间的属性。 As soon as the master player leaves the room, an exception is triggered: Operation setProperties (252) not called because client is not connected or not ready yet, client state: Leaving.主玩家一离开房间,就会触发异常:Operation setProperties (252) not call because client is not connected or not ready, client state: Leaving。 This error does not affect the operation, there is no such error when another player exits.此错误不影响操作,其他玩家退出时不会出现此错误。 How can I handle this exception?我该如何处理这个异常? It just bothers the eyes.它只是打扰眼睛。

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();
    }
}

Here is the code that most likely causes this error.这是最有可能导致此错误的代码。

You could try你可以试试

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM