1
This commit is contained in:
@@ -973,19 +973,26 @@ public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
/// 数据来自服务端下发的 RoomInfo.players / RoomJoinNotice):
|
||||
/// 玩家ID、昵称、头像、VIP 图标(0~10 级一一对应)、VIP 等级背景(每两级一个)。
|
||||
/// </summary>
|
||||
/// <param name="userId">玩家唯一 ID(显示在 tmp_UserNumber)</param>
|
||||
/// <param name="userId">玩家唯一 ID(用于判断是否本人)</param>
|
||||
/// <param name="userName">玩家昵称(显示在 tmp_UserName)</param>
|
||||
/// <param name="avatar">头像名/URL(走 GameManager 头像缓存,找不到回退默认头像)</param>
|
||||
/// <param name="vipLevel">VIP 等级 0~10</param>
|
||||
public void SetUserInfo(string userId, string userName, string avatar, int vipLevel)
|
||||
/// <param name="userNumber">玩家编号(短ID,显示在 tmp_UserNumber;空则回退显示 userId)</param>
|
||||
public void SetUserInfo(string userId, string userName, string avatar, int vipLevel, string userNumber = null)
|
||||
{
|
||||
// 玩家 ID
|
||||
if (tmp_UserNumber != null && !string.IsNullOrEmpty(userId))
|
||||
tmp_UserNumber.text = userId;
|
||||
// 玩家 ID:优先显示后端下发的短编号 UserNumber,没有再用 userId
|
||||
if (tmp_UserNumber != null)
|
||||
{
|
||||
string displayId = string.IsNullOrEmpty(userNumber) ? userId : userNumber;
|
||||
if (!string.IsNullOrEmpty(displayId))
|
||||
tmp_UserNumber.text = displayId;
|
||||
}
|
||||
|
||||
// 昵称
|
||||
// 昵称:非本人的名字打码(前2后2保留,中间***),自己原样显示
|
||||
if (tmp_UserName != null && !string.IsNullOrEmpty(userName))
|
||||
tmp_UserName.text = userName;
|
||||
tmp_UserName.text = userId == GameManager.Instance?.user?.id
|
||||
? userName
|
||||
: MaskUserName(userName);
|
||||
|
||||
// 头像:优先 GameManager 头像缓存(Resources/Avatar),查不到用默认头像
|
||||
if (img_Head != null)
|
||||
@@ -1018,6 +1025,17 @@ public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 非本人昵称打码:保留前 2 位和后 2 位,中间用 *** 代替。
|
||||
/// 例:123456789 → 12***89;12345 → 12***45。不足 5 位原样显示。
|
||||
/// </summary>
|
||||
private static string MaskUserName(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || name.Length < 5)
|
||||
return name;
|
||||
return name.Substring(0, 1) + "***" + name.Substring(name.Length - 1);
|
||||
}
|
||||
|
||||
#region 表情包显示(spineObj / ziObj)
|
||||
|
||||
/// <summary>表情显示时长(秒),超时自动隐藏</summary>
|
||||
|
||||
Reference in New Issue
Block a user