12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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;
- 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>());
- }
- }
- }
|