12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using TMPro;
- using UnityEngine;
- using UnityEngine.UI;
- public class InviteUserItem : MonoBehaviour
- {
- public TMP_Text mUserName_Text; // 用户名
- public TMP_Text mLevel_Text; // 级别
- public Image mState_Image; // 状态
- public TMP_Text mState_Text; // 状态
- public Image mHead_Image; // 头像
- public Toggle toggle;
- public RTCUserInfo mCurrentRTCUserInfo = null;
- private void Start()
- {
- toggle.onValueChanged.AddListener((state) =>
- {
- OnValueChange(state);
- });
- }
- public void InitData(Sprite headImage, RTCUserInfo userInfo)
- {
- if(userInfo==null) return;
- if (headImage != null) this.mHead_Image.sprite = headImage;
- mUserName_Text.text = userInfo.UserName;
- this.mLevel_Text.text = userInfo.Level;
- this.mCurrentRTCUserInfo = userInfo;
- switch (userInfo.State)
- {
- case "1":
- mState_Image.color = Color.green;
- mState_Text.text = "在线";
- toggle.interactable = true;
- break;
- case "2":
- mState_Image.color = Color.blue;
- mState_Text.text = "通话中";
- toggle.interactable = false;
- break;
- case "0":
- mState_Image.color = Color.red;
- mState_Text.text = "离线";
- toggle.interactable = false;
- break;
- default:
- break;
- }
- }
- public void ResetData()
- {
- mUserName_Text.text = "韩风";
- this.mLevel_Text.text = "组长";
- mState_Image.color = Color.red;
- mState_Text.text = "离线";
- mCurrentRTCUserInfo = null;
- }
- private void OnValueChange(bool isOn)
- {
- if (mCurrentRTCUserInfo != null)
- {
- InviteUserPanel.Instance.SelectInviteUser(mCurrentRTCUserInfo, isOn);
- }
- }
- }
|