优化
This commit is contained in:
@@ -11,8 +11,8 @@ namespace Script
|
||||
{
|
||||
public class ContactEntryController : MonoBehaviour, IController
|
||||
{
|
||||
private Transform _background;
|
||||
private Transform _backgroundName;
|
||||
private Image _background;
|
||||
private Text _backgroundName;
|
||||
private GameObject _confirmBtnTime;
|
||||
private Text _confirmBtnTimeText;
|
||||
private Button _confirmButton;
|
||||
@@ -37,36 +37,24 @@ namespace Script
|
||||
{
|
||||
_usersItem = item;
|
||||
_meetingContacts = meetingContactsController;
|
||||
|
||||
_background = transform.Find("headBackground/image").GetComponent<Image>();
|
||||
_backgroundName = transform.Find("headBackground/Name").GetComponent<Text>();
|
||||
///头像赋值
|
||||
if (string.IsNullOrEmpty(item.avatar))
|
||||
{
|
||||
var randomColor = WebRTCUtil.GetRandomColor();
|
||||
_background = transform.Find("headBackground");
|
||||
if (_background != null)
|
||||
{
|
||||
var image = _background.GetComponent<Image>();
|
||||
if (image != null) image.color = randomColor;
|
||||
}
|
||||
|
||||
_backgroundName = _background.transform.Find("Name");
|
||||
if (_background != null) _background.color = randomColor;
|
||||
if (_backgroundName != null)
|
||||
{
|
||||
var textComponent = _backgroundName.GetComponent<Text>();
|
||||
if (textComponent != null && !string.IsNullOrEmpty(item.name))
|
||||
textComponent.text = item.name.Substring(0, 1);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(item.name))
|
||||
_backgroundName.text = item.name.Substring(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_background = transform.Find("headBackground");
|
||||
if (_background != null)
|
||||
{
|
||||
var imageComponent = _background.GetComponent<Image>();
|
||||
if (imageComponent != null) WebRTCUtil.DownloadAndSetAvatar(item.avatar, imageComponent);
|
||||
}
|
||||
|
||||
_backgroundName = _background.transform.Find("Name");
|
||||
if (_backgroundName != null) _backgroundName.GetComponent<Text>().text = "";
|
||||
if (_background != null)
|
||||
WebRTCUtil.DownloadAndSetAvatar(item.avatar, _background);
|
||||
if (_backgroundName != null) _backgroundName.text = "";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.name))
|
||||
|
||||
Reference in New Issue
Block a user