123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- public class MsgItem : MonoBehaviour
- {
- public Image headImage;
- public TMP_Text nameText;
- public string msgType;
- public FileItem fileItem;
- public List<ContentSizeFitter> refreshFitter;
- public GameObject messageItem;
- public Text msgText;
- private FileConfig fileConfig;
- public void Init( Sprite headImage, string name , string message )
- {
- if (headImage != null)
- this.headImage.sprite = headImage;
- nameText.text = name;
- this.fileItem.gameObject.SetActive(false);
- this.messageItem.SetActive(true);
- msgText.text = message;
- StartCoroutine(Refresh());
- }
- public void Init(Sprite headImage, FileConfig fileConfig)
- {
- this.fileConfig = fileConfig;
- fileItem.Init(fileConfig);
- nameText.text = fileConfig.From;
- this.fileItem.gameObject.SetActive(true);
- this.messageItem.SetActive(false);
- if (headImage != null)
- this.headImage.sprite = headImage;
- }
- private IEnumerator Refresh()
- {
- int i = 0;
- while(i<refreshFitter.Count)
- {
- yield return new WaitForFixedUpdate();
- LayoutRebuilder.ForceRebuildLayoutImmediate(refreshFitter[i++].GetComponent<RectTransform>());
- }
- }
- }
|