using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ChatTextItem_Private : ItemBase { public Text TextContent; public Image Background; public override void Init() { } public override void UpdateItemData() { TextContent.text = Data.Data; } public override void UpdateItemSize() { TextContent.GetComponent().SetLayoutVertical(); Vector2 size = Background.GetComponent().sizeDelta; size.x = TextContent.GetComponent().sizeDelta.x + 20; size.y = TextContent.GetComponent().sizeDelta.y + 20; Background.GetComponent().sizeDelta = size; RectTransform tf = gameObject.GetComponent(); float y = size.y < 75 ? 75 : size.y; tf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y); } }