备份CatanBuilding瘦身独立工程
This commit is contained in:
55
Assets/Scripts/UI/HomeReport/ReportBase.cs
Normal file
55
Assets/Scripts/UI/HomeReport/ReportBase.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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<IUserService>();
|
||||
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
|
||||
text_name = transform.Find("info/text_name")?.GetComponent<TMP_Text>();
|
||||
head = transform.Find("btn_head").GetComponent<Head>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user