我有一个公共房间列表。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 tensorflow 2.16
安装时出现了问题
请参阅链接以获取解决方案。
https://discuss.tensorflow.org/t/tensorflow-version-2-16-just-released/23140
https://github.com/tensorflow/tensorflow/issues/63362
如果您想使用 2.16.1 并且使用 conda,那么最简单的修复方法是激活环境:
mkdir -p ${CONDA_PREFIX}/etc/conda/activate.d
创建 ${CONDA_PREFIX}/etc/conda/activate.d/fix_gpu.sh
包含以下内容的文件:
NVIDIA_DIR=$(dirname $(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)")))
for dir in $NVIDIA_DIR/*; do
if [ -d "$dir/lib" ]; then
export LD_LIBRARY_PATH="$dir/lib:$LD_LIBRARY_PATH"
fi
done