using System; using System.Collections; using System.IO; using RenderStreaming; using Script.Util; using Stary.Evo; using UnityEngine; using UnityEngine.UI; namespace Script { public class ContactEntryController : MonoBehaviour, IController { private Image _background; private Text _backgroundName; private GameObject _confirmBtnTime; private Text _confirmBtnTimeText; private Button _confirmButton; private bool _isCountingDown; private MeetingContactsController _meetingContactsController; private Transform _messageText; private Transform _nameText; private MainPanel.UsersItem _usersItem; private void OnDestroy() { StopAllCoroutines(); _isCountingDown = false; } public IArchitecture GetArchitecture() { return MainArchitecture.Interface; } public void SetData(MainPanel.UsersItem item, MeetingContactsController meetingContactsControllerController) { _usersItem = item; _meetingContactsController = meetingContactsControllerController; _background = transform.Find("headBackground/image").GetComponent(); _backgroundName = transform.Find("headBackground/Name").GetComponent(); ///头像赋值 if (string.IsNullOrEmpty(item.avatar)) { var randomColor = WebRTCUtil.GetRandomColor(); if (_background != null) _background.color = randomColor; if (_backgroundName != null) if (!string.IsNullOrEmpty(item.name)) _backgroundName.text = item.name.Substring(0, 1); } else { if (_background != null) if (_background != null) WebRTCUtil.DownloadAndSetAvatar(item.avatar, _background); if (_backgroundName != null) _backgroundName.text = ""; } if (!string.IsNullOrEmpty(item.name)) _nameText = transform.Find("Name"); if (_nameText != null) { var textComponent = _nameText.GetComponent(); if (textComponent != null) textComponent.text = item.name; } if (!string.IsNullOrEmpty(item.userId)) { _messageText = transform.Find("Message"); if (_messageText != null) { var textComponent = _messageText.GetComponent(); if (textComponent != null) textComponent.text = item.userId; } } if (!string.IsNullOrEmpty(item.role)) { var role = item.role; var idle = transform.Find("Name/state/idle"); var participant = transform.Find("Name/state/participant"); var host = transform.Find("Name/state/host"); if (role.Equals("host")) { host.gameObject.SetActive(true); participant.gameObject.SetActive(false); idle.gameObject.SetActive(false); } else if (role.Equals("participant")) { participant.gameObject.SetActive(true); host.gameObject.SetActive(false); idle.gameObject.SetActive(false); } else if (role.Equals("idle")) { idle.gameObject.SetActive(true); host.gameObject.SetActive(false); participant.gameObject.SetActive(false); } } _confirmButton = transform.Find("callBtn").GetComponent