You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class ChatTextItem : ItemBase<ChatTextMessage> |
|
{ |
|
// 用户姓名 |
|
public Text UserName; |
|
// 文本内容 |
|
public Text TextContent; |
|
|
|
public override void Init() |
|
{ |
|
|
|
} |
|
|
|
public override void UpdateItemData() |
|
{ |
|
// 获取发送人 |
|
long senderId = Data.SenderId; |
|
UserData user = CurrentUserInfo.room.FindUserById(senderId); |
|
// 设置发送人姓名 |
|
UserName.text = string.Format("{0}", user != null ? user.UserInfo.RealName : "系统"); |
|
// 获取发送内容 |
|
TextContent.text = Data.Data; |
|
} |
|
|
|
public override void UpdateItemSize() |
|
{ |
|
// 重新设置Item的大小位置 |
|
TextContent.GetComponent<ContentSizeFitter>().SetLayoutVertical(); |
|
Vector2 size = TextContent.GetComponent<RectTransform>().sizeDelta; |
|
RectTransform tf = gameObject.GetComponent<RectTransform>(); |
|
float y = Mathf.Max(size.y, 30); |
|
tf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y); |
|
} |
|
}
|
|
|