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.
38 lines
1.1 KiB
38 lines
1.1 KiB
4 years ago
|
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class SuggestTextItem : ItemBase<ChatTextMessage> {
|
||
|
|
||
|
public Text Content;
|
||
|
public Text SendTime;
|
||
|
public Image Background;
|
||
|
|
||
|
public override void Init()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void UpdateItemData()
|
||
|
{
|
||
|
// 设置聊天内容,发送时间
|
||
|
Content.text = Data.Data;
|
||
|
SendTime.text = Data.CreateTime.ToShortTimeString();
|
||
|
}
|
||
|
|
||
|
public override void UpdateItemSize()
|
||
|
{
|
||
|
Content.GetComponent<ContentSizeFitter>().SetLayoutVertical();
|
||
|
Vector2 textSize = Content.GetComponent<RectTransform>().sizeDelta;
|
||
|
Vector2 backSize = Background.GetComponent<RectTransform>().sizeDelta;
|
||
|
backSize = new Vector2(backSize.x, textSize.y + 50);
|
||
|
Background.GetComponent<RectTransform>().sizeDelta = backSize;
|
||
|
float y = Mathf.Max(backSize.y, 69);
|
||
|
RectTransform rt = gameObject.GetComponent<RectTransform>();
|
||
|
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y);
|
||
|
}
|
||
|
}
|