用户加入时不调用 OnJoinedRoom 方法 [英] The OnJoinedRoom method is not called when the user joins

查看:25
本文介绍了用户加入时不调用 OnJoinedRoom 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Unity Pun2 开发服务器.

I am developing a server using Unity Pun2.

我的问题是当用户参与时没有调用 OnJoinedRoom().

My problem is that the OnJoinedRoom() is not called when the user participates.

有两种情况

  1. 创建房间并首次添加时 - 称为

  1. When making a room and adding it for the first time - called

然后,当另一方加入房间时 - 不叫

Then, when another party joins the room - not called

public override void OnJoinedRoom()
{

    if (PhotonNetwork.CurrentRoom.PlayerCount == 1)
    {
        PhotonNetwork.LoadLevel("RoomFor1");
    }
}

++我的问题是主客户端称为 OnJoinedRoom,但其他客户端不称为 OnJoinedRoom.

++ my problem is that the master client is called OnJoinedRoom, but the other clients are not called OnJoinedRoom.

推荐答案

使用 OnPlayerEnteredRoom() 检查是否另一个玩家进入了你所在的房间

use OnPlayerEnteredRoom() to check if another player entered the room you are in

使用 OnJoinedRoom() 检查自己是否成功加入房间

use OnJoinedRoom() to check if you yourself have successfully joined a room

这篇关于用户加入时不调用 OnJoinedRoom 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆