我有一个公共房间列表。public override void OnRoomListUpdate(List)
我有一个公共房间列表。
public override void OnRoomListUpdate(List<RoomInfo> roomList)
{
foreach (RoomInfo room in roomList)
{
if (room.RemovedFromList)
{
cachedRoomList.Remove(room);
}
else
{
int index = cachedRoomList.FindIndex(r => r.Name == room.Name);
if (index != -1)
{
cachedRoomList[index] = room;
}
else
{
cachedRoomList.Add(room);
}
}
}
UpdatePublicRoomUI();
}
void UpdatePublicRoomUI()
{
foreach (Transform roomButton in publicRoomContainer)
{
Destroy(roomButton.gameObject);
}
foreach (RoomInfo room in cachedRoomList)
{
CreatePublicRoomButton(room.Name, room.PlayerCount);
}
}
void CreatePublicRoomButton(string roomName, int playerCount)
{
GameObject roomButton = Instantiate(publicRoomButton, publicRoomContainer);
roomButton.SetActive(true);
roomButton.transform.GetChild(0).GetComponent<TextMeshProUGUI>().SetText(roomName);
roomButton.transform.GetChild(1).GetComponent<TextMeshProUGUI>().SetText(playerCount.ToString());
UnityEngine.UI.Button button = roomButton.GetComponent<UnityEngine.UI.Button>();
button.onClick.AddListener(() =>
{
JoinRoom(roomName);
});
}
因此基本上,每个将选项 IsVisible
设置为 true 的房间都会显示在这里。一切正常,直到玩家离开房间然后创建一个房间。无论房间是否公开,它都不会显示在这里。以下是离开房间的代码:
public void QuitToMenu()
{
if (PhotonNetwork.InRoom)
{
PhotonNetwork.LeaveRoom();
PhotonNetwork.LoadLevel("Menu");
}
}
以下是创建和加入房间的功能:
public void CreateRoom(string roomName, bool isPublic)
{
RoomOptions roomOptions = new()
{
IsVisible = isPublic,
IsOpen = true,
MaxPlayers = 10
};
PhotonNetwork.CreateRoom(roomName, roomOptions);
}
public void JoinRoom(string roomName)
{
PhotonNetwork.JoinRoom(roomName);
}
public override void OnJoinedRoom()
{
string nickname = nickname_input.text.Trim();
if (nickname.Length > 0)
{
PlayerPrefs.SetString("Nickname", nickname);
PhotonNetwork.NickName = nickname;
}
PhotonNetwork.LoadLevel("Game");
}
看到它正常工作真是太棒了。提前致谢。
我正在尝试在 Ubuntu 22.04.3 LTS 上全局安装 osmtogeojson,如下所示;npm install -g osmtogeojson 我收到以下错误消息;npm ERR!无法读取未定义的属性“then”...
我正在尝试在 Ubuntu 22.04.3 LTS 上全局安装 osmtogeojson,如下所示;
npm install -g osmtogeojson
我收到以下错误消息;
npm ERR! Cannot read property 'then' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2024-05-24T23_49_38_390Z-debug-0.log
以下是上面引用的日志文件的内容:
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '-g', 'osmtogeojson' ]
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 6ms
8 timing config:load:env Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/root/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 1ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 13ms
18 timing npm:load:configload Completed in 14ms
19 timing npm:load:setTitle Completed in 0ms
20 timing config:load:flatten Completed in 2ms
21 timing npm:load:display Completed in 5ms
22 verbose logfile /root/.npm/_logs/2024-05-24T23_49_38_390Z-debug-0.log
23 timing npm:load:logFile Completed in 5ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 24ms
27 timing arborist:ctor Completed in 1ms
28 timing idealTree:init Completed in 9ms
29 timing idealTree:userRequests Completed in 3ms
30 silly idealTree buildDeps
31 silly fetch manifest osmtogeojson@*
32 verbose stack TypeError: Cannot read property 'then' of undefined
32 verbose stack at /usr/share/nodejs/cacache/lib/util/fix-owner.js:113:7
33 verbose cwd /
34 verbose Linux 5.15.0-91-generic
35 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "osmtogeojson"
36 verbose node v12.22.9
以下是包含行号 113 的函数;
106 function mkdirfix (cache, p, cb) {
107 // we have to infer the owner _before_ making the directory, even though
108 // we aren't going to use the results, since the cache itself might not
109 // exist yet. If we mkdirp it, then our current uid/gid will be assumed
110 // to be correct if it creates the cache folder in the process.
111 return Promise.resolve(inferOwner(cache)).then(() => {
112 return mkdirp(p)
113 .then((made) => {
114 if (made) {
115 return fixOwner(cache, made).then(() => made)
116 }
117 })
118 .catch((err) => {
119 if (err.code === 'EEXIST') {
120 return fixOwner(cache, p).then(() => null)
121 }
122 throw err
123 })
124 })
125 }
我不明白这个函数,但它似乎在 mkdir(p) 上出错了,对吧?我也在以 root 身份运行 osmtogeojson 的安装。另外,里面有一些关于缓存的东西我不明白。
我尝试搜索此错误,但找不到任何相关信息。非常感谢您的帮助。