using asap.core; using game; using System; using TMPro; using UniRx; using UnityEngine; public class ReportBase : MonoBehaviour { TMP_Text text_name; Head head; IUserService userService; IDisposable disposable; string playFabId; protected virtual void Awake() { userService = GContext.container.Resolve(); disposable = GContext.OnEvent().Where(x => x.id == playFabId).Subscribe(SetAvatar); text_name = transform.Find("info/text_name")?.GetComponent(); head = transform.Find("btn_head").GetComponent(); } public void Init(string playFabId) { this.playFabId = playFabId; PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId); SetAvatar(clubPlayInfo); } void SetAvatar(PlayInfo clubPlayInfo) { if (clubPlayInfo != null) { if (text_name != null) { text_name.text = clubPlayInfo.name; } head.SetData(clubPlayInfo.avatarUrl); } } void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent) { if (getClubPlayInfoEvent.id == playFabId) { text_name.text = getClubPlayInfoEvent.name; head.SetData(getClubPlayInfoEvent.avatarUrl); } } private void OnDestroy() { disposable?.Dispose(); disposable = null; } }