68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
using UnityEngine.UI;
|
|
|
|
public class PCInfoUI_Center : UI3DModel
|
|
{
|
|
public TextMeshProUGUI[] texts; // 0 코스튬 이름, 1 코스튬 대사
|
|
public RawImage RawImage_costume;
|
|
public GameObject[] gos; // 0 코스튬 착용 버튼
|
|
|
|
public int CostumeIdWhenEnter;
|
|
|
|
PCInfoUI_PCListCard SelectCard;
|
|
AsyncOperationHandle<Texture> currentHandle;
|
|
|
|
public void Set(bool enter, PCInfoUI_PCListCard choiceCard)
|
|
{
|
|
if (!DSUtil.CheckNull(SelectCard))
|
|
SelectCard.gos[0].SetActive(false);
|
|
|
|
SelectCard = choiceCard;
|
|
SelectCard.gos[0].SetActive(true);
|
|
|
|
if (enter) CostumeIdWhenEnter = choiceCard.Get_IntData();
|
|
|
|
var costumeid = SelectCard.Get_IntData();
|
|
var costumeData = table_costumelist.Ins.Get_Data_orNull(costumeid);
|
|
RawImage_costume.enabled = false;
|
|
if (!DSUtil.CheckNull(costumeData))
|
|
{
|
|
AddrResourceMgr.Ins.LoadObject<Texture>($"Assets/Res_Addr/PCCostumeImage/{costumeData.s_Image}.png", handle =>
|
|
{
|
|
if (currentHandle.IsValid())
|
|
{
|
|
Addressables.Release(currentHandle);
|
|
RawImage_costume.texture = null; // 기존 Texture 참조 해제
|
|
}
|
|
|
|
currentHandle = handle;
|
|
RawImage_costume.enabled = true;
|
|
RawImage_costume.texture = handle.Result;
|
|
});
|
|
|
|
Set_3DModel($"Assets/Res_Addr/PC/{costumeData.s_Prefab}.prefab");
|
|
}
|
|
|
|
gos[0].SetActive(CanEquip());
|
|
}
|
|
|
|
bool CanEquip()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var costumeid = SelectCard.Get_IntData();
|
|
if (sdata.Get_EqiupmentEquip(eItem.PCCostume) == costumeid || !sdata.IsObtainItem(costumeid))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
public void OnClick_EquipCostume()
|
|
{
|
|
if (!CanEquip()) return;
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
sdata.Equip.Set_Equip(eItem.PCCostume, SelectCard.Get_IntData());
|
|
PCInfoUI.Ins.Set_UI(false);
|
|
}
|
|
} |