光子创建新房间而不是连接到已经存在的房间?

发布于 2025-02-06 08:34:40 字数 1087 浏览 1 评论 0原文

当我创建游戏的构建时,一切正常工作。但是,当第二个玩家试图用名称连接到房间时,它说房间不存在,如果我创建了一个带有第一个房间名称的房间,它将被创建,而不是说“房间已经存在”。

我认为这可能是一个区域问题,但是在PhotonServerSettings中,“固定区域”设置为“ EU”,“使用名称服务器”,然后将“ Dev region”设置为NULL(将其设置为空)。在构建设置中,我将“开发构建”设置为false。

我不明白为什么这两个游戏不会根据我之前提到的内容在同一区域?

photonserversettings的图片

这是用于创建/加入房间的代码:

public void CreateRoom()
{
    if (string.IsNullOrEmpty(CreateInputField.text))
    {
        return;
    }
    PhotonNetwork.CreateRoom(CreateInputField.text);
}
public void JoinRoom()
{
    if (string.IsNullOrEmpty(JoinInputField.text))
    {
        return;
    }
    PhotonNetwork.JoinRoom(JoinInputField.text);
}
public override void OnJoinedRoom()
{
    PhotonNetwork.LoadLevel("Game");
}

public override void OnCreateRoomFailed(short returnCode, string message)
{
    failText.text = message;
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
    failText.text = message;
}

}

(出于某种原因,我不能放整个脚本,但这些是重要的部分)

When I create a build of the game, everything works normally. However, when the second player tries to connect to the room with the name, it says that the room does not exist and if I create a room with the first rooms name it gets created instead of saying "room already exists".

I thought it could be a region problem, but in PhotonServerSettings, the "Fixed Region" is set to "eu", "Use Name Server" checked on, and "Dev Region" set to null (left it empty). In the build settings I set "development build" to false.

I don't understand why the two games would not be in the same region based on what I mentioned before?

Picture of the PhotonServerSettings

This is the code for creating/joining a room:

public void CreateRoom()
{
    if (string.IsNullOrEmpty(CreateInputField.text))
    {
        return;
    }
    PhotonNetwork.CreateRoom(CreateInputField.text);
}
public void JoinRoom()
{
    if (string.IsNullOrEmpty(JoinInputField.text))
    {
        return;
    }
    PhotonNetwork.JoinRoom(JoinInputField.text);
}
public override void OnJoinedRoom()
{
    PhotonNetwork.LoadLevel("Game");
}

public override void OnCreateRoomFailed(short returnCode, string message)
{
    failText.text = message;
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
    failText.text = message;
}

}

(for some reason I cant put the entire script but these are the important parts)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文