49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ClubHead : MonoBehaviour
|
|
{
|
|
public Image bg_head;
|
|
public Image icon_head;
|
|
#if UNITY_EDITOR
|
|
private void Reset()
|
|
{
|
|
Awake();
|
|
}
|
|
#endif
|
|
private void Awake()
|
|
{
|
|
bg_head = transform.Find("bg_head").GetComponent<Image>();
|
|
icon_head = transform.Find("icon_head").GetComponent<Image>();
|
|
}
|
|
|
|
public void SetData(string avatars)
|
|
{
|
|
if (string.IsNullOrEmpty(avatars) || !avatars.Contains('#'))
|
|
{
|
|
int id = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitAvatar;
|
|
int frameId = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubInitFrame;
|
|
avatars = $"{GContext.container.Resolve<Tables>().TbClubAvatar[id].Avatar}#{GContext.container.Resolve<Tables>().TbClubFrame[frameId].Frame}";
|
|
}
|
|
string[] icon_frame = avatars.Split('#');
|
|
|
|
string avatar = icon_frame[0];
|
|
string frame = icon_frame[1];
|
|
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(icon_head, avatar);
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(bg_head, frame);
|
|
//GetSpriteEvent getSpriteEvent = new GetSpriteEvent(avatar);
|
|
//icon_head.sprite = getSpriteEvent.sprite;
|
|
}
|
|
public void SetIcon(string avatar)
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(icon_head, avatar);
|
|
}
|
|
public void SetFrame(string frame)
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(bg_head, frame);
|
|
}
|
|
}
|