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 Transform _background; private Transform _backgroundName; private GameObject _confirmBtnTime; private Text _confirmBtnTimeText; private Button _confirmButton; private bool _isCountingDown; private MeetingContacts _meetingContacts; 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, MeetingContacts meetingContactsController) { _usersItem = item; _meetingContacts = meetingContactsController; ///头像赋值 if (string.IsNullOrEmpty(item.avatar)) { var randomColor = WebRTCUtil.GetRandomColor(); _background = transform.Find("headBackground"); if (_background != null) { var image = _background.GetComponent(); if (image != null) image.color = randomColor; } _backgroundName = _background.transform.Find("Name"); if (_backgroundName != null) { var textComponent = _backgroundName.GetComponent(); if (textComponent != null && !string.IsNullOrEmpty(item.name)) textComponent.text = item.name.Substring(0, 1); } } else { _background = transform.Find("headBackground"); if (_background != null) { var imageComponent = _background.GetComponent(); if (imageComponent != null) WebRTCUtil.DownloadAndSetAvatar(item.avatar, imageComponent); } _backgroundName = _background.transform.Find("Name"); if (_backgroundName != null) _backgroundName.GetComponent().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