fix: 아이콘이 정상적으로 출력되지 않는 오류 수정
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
@@ -18,11 +16,11 @@ namespace TON
|
||||
|
||||
|
||||
public Transform skillButtonGroup;
|
||||
public ControllerUI_SkillButton skillButtonPrefab;
|
||||
private List<ControllerUI_SkillButton> createdSkillButtons = new List<ControllerUI_SkillButton>();
|
||||
public SkillButtonItem skillButtonPrefab;
|
||||
private List<SkillButtonItem> createdSkillButtons = new List<SkillButtonItem>();
|
||||
|
||||
public UserItemData userItem { get; private set; } = new UserItemData();
|
||||
// 보유 포션 수량
|
||||
// 보유 포션 수량
|
||||
[SerializeField] private TextMeshProUGUI hpPotionCount;
|
||||
[SerializeField] private TextMeshProUGUI mpPotionCount;
|
||||
|
||||
@@ -30,7 +28,7 @@ namespace TON
|
||||
private int hpPotion = 0;
|
||||
private int mpPotion = 0;
|
||||
|
||||
public List<ControllerUI_ItemButton> itemButtons = new List<ControllerUI_ItemButton>();
|
||||
public List<PotionButtonItem> itemButtons = new List<PotionButtonItem>();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -60,7 +58,7 @@ namespace TON
|
||||
List<SkillBase> activatedSkills = SkillDataManager.Singleton.GetEquippedSkills();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ControllerUI_SkillButton newSkillButton = Instantiate(skillButtonPrefab, skillButtonGroup);
|
||||
SkillButtonItem newSkillButton = Instantiate(skillButtonPrefab, skillButtonGroup);
|
||||
newSkillButton.gameObject.SetActive(true);
|
||||
|
||||
if (i < activatedSkills.Count) // 해당 인덱스에 활성화된 스킬이 있을 경우
|
||||
@@ -69,7 +67,7 @@ namespace TON
|
||||
}
|
||||
else
|
||||
{
|
||||
// 복제 됐을때 기본 상태가 잠금 상태
|
||||
// 복제 됐을때 기본 상태가 잠금 상태
|
||||
newSkillButton.GetComponent<Button>().interactable = false;
|
||||
}
|
||||
|
||||
@@ -141,7 +139,7 @@ namespace TON
|
||||
linkedCharactor.Attack();
|
||||
}
|
||||
|
||||
public void OnClickSkillButton(ControllerUI_SkillButton button)
|
||||
public void OnClickSkillButton(SkillButtonItem button)
|
||||
{
|
||||
linkedCharactor.SkillAttack(button.skillBase.SkillData.id);
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class ControllerUI_ItemButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI coolTimeText;
|
||||
[SerializeField] private Image coolTimeDimd;
|
||||
|
||||
private float currentCoolDown = 0f;
|
||||
private float potionCoolDown = 5f;
|
||||
|
||||
public void SetCurrentCoolDown()
|
||||
{
|
||||
currentCoolDown = potionCoolDown; // 쿨타임 시작
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (currentCoolDown == 0f)
|
||||
return;
|
||||
|
||||
UpdateCooldownUI();
|
||||
}
|
||||
|
||||
private void UpdateCooldownUI()
|
||||
{
|
||||
if (coolTimeText == null || coolTimeDimd == null)
|
||||
{
|
||||
return; // UI가 삭제되었으면 업데이트 중단
|
||||
}
|
||||
|
||||
currentCoolDown -= Time.deltaTime;
|
||||
currentCoolDown = Mathf.Max(0, currentCoolDown);
|
||||
|
||||
coolTimeText.gameObject.SetActive(currentCoolDown > 0); // 남은 쿨타임이 있을 때만 표시
|
||||
|
||||
if (coolTimeText.IsActive())
|
||||
{
|
||||
coolTimeText.text = $"{currentCoolDown: 0}s"; // 정수 초단위 표시
|
||||
coolTimeDimd.fillAmount = currentCoolDown / potionCoolDown; // 1 → 0 으로 감소
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e890b5f706c997b4396fb3fc11938954
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,68 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class ControllerUI_SkillButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI coolTimeText;
|
||||
[SerializeField] private Image coolTimeDimd;
|
||||
[SerializeField] private GameObject skillIcon;
|
||||
[SerializeField] private GameObject lockImage;
|
||||
|
||||
public SkillBase skillBase;
|
||||
|
||||
|
||||
public void Initalize(SkillBase skillData)
|
||||
{
|
||||
if (skillData != null)
|
||||
{
|
||||
skillData.OnSkillExecuted -= OnSkillExecuted;
|
||||
// skillData.OnCooldownCompleted -= OnCooldownCompleted;
|
||||
}
|
||||
|
||||
skillBase = skillData;
|
||||
skillData.OnSkillExecuted += OnSkillExecuted;
|
||||
// skillData.OnCooldownCompleted += OnCooldownCompleted;
|
||||
|
||||
skillIcon.SetActive(true);
|
||||
|
||||
// out 으로 받을 변수 초기화
|
||||
Sprite loadedSkillImage = null;
|
||||
Assert.IsTrue(AssetManager.Singleton.LoadSkillIcon(skillBase.SkillData.id, out loadedSkillImage));
|
||||
skillIcon.GetComponent<Image>().sprite = loadedSkillImage;
|
||||
lockImage.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnSkillExecuted()
|
||||
{
|
||||
UpdateCooldownUI();
|
||||
}
|
||||
|
||||
private void UpdateCooldownUI()
|
||||
{
|
||||
if (coolTimeText == null || coolTimeDimd == null)
|
||||
{
|
||||
return; // UI가 삭제되었으면 업데이트 중단
|
||||
}
|
||||
|
||||
coolTimeText.gameObject.SetActive(skillBase.CurrentCoolDown > 0); // 남은 쿨타임이 있을 때만 표시
|
||||
|
||||
if (coolTimeText.IsActive())
|
||||
{
|
||||
coolTimeText.text = $"{skillBase.CurrentCoolDown: 0}s"; // 정수 초단위 표시
|
||||
coolTimeDimd.fillAmount = skillBase.CurrentCoolDown / skillBase.SkillCoolDown; // 1 → 0 으로 감소
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateCooldownUI(); // UI 업데이트
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35c94c75c6e511048b4a77d3682e1f85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
@@ -8,7 +7,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class RankingUI_RankBox : MonoBehaviour
|
||||
public class RankBoxItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject rankBoxImage;
|
||||
[SerializeField] private GameObject pawImage;
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f063d17b315ac49b03acf8e9dd20b4
|
||||
guid: 4d47caa84e9a090419eb82f5e455a86d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,9 +13,9 @@ namespace TON
|
||||
|
||||
// 전체 랭킹 리스트를 스크롤 형식으로 구현하기 위함
|
||||
public ScrollRect scrollRect;
|
||||
public RankingUI_RankBox rankBoxPrefab;
|
||||
public RankBoxItem rankBoxPrefab;
|
||||
public List<RectTransform> uiPrefabList = new List<RectTransform>();
|
||||
public List<RankingUI_RankBox> createRankList = new List<RankingUI_RankBox>();
|
||||
public List<RankBoxItem> createRankList = new List<RankBoxItem>();
|
||||
|
||||
[SerializeField] private GameObject errorPopup;
|
||||
[SerializeField] private GameObject pawImage;
|
||||
@@ -76,7 +76,7 @@ namespace TON
|
||||
for (int i = 0; i < rankList.Count; i++)
|
||||
{
|
||||
ClearData clearData = rankList[i];
|
||||
RankingUI_RankBox rankBox = Instantiate(rankBoxPrefab, scrollRect.content);
|
||||
RankBoxItem rankBox = Instantiate(rankBoxPrefab, scrollRect.content);
|
||||
|
||||
rankBox.gameObject.SetActive(true);
|
||||
rankBox.Initalize(i + 1, clearData);
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace TON
|
||||
|
||||
// 사용할 스킬 슬롯 3개 매핑을 위한 변수
|
||||
public Transform skillSlotGroup;
|
||||
public SkillSettingUI_SkillSlot skillSlotPrefab;
|
||||
public List<SkillSettingUI_SkillSlot> createSkillSlots = new List<SkillSettingUI_SkillSlot>();
|
||||
public SkillSettingSlot skillSlotPrefab;
|
||||
public List<SkillSettingSlot> createSkillSlots = new List<SkillSettingSlot>();
|
||||
|
||||
// 전체 스킬 리스트를 스크롤 형식으로 구현하기 위함
|
||||
public ScrollRect scrollRect;
|
||||
@@ -73,7 +73,7 @@ namespace TON
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
SkillSettingUI_SkillSlot newSkillSlot = Instantiate(skillSlotPrefab, skillSlotGroup);
|
||||
SkillSettingSlot newSkillSlot = Instantiate(skillSlotPrefab, skillSlotGroup);
|
||||
newSkillSlot.gameObject.SetActive(true);
|
||||
|
||||
if (skillMap.TryGetValue(i, out SkillBase skill))
|
||||
@@ -144,7 +144,7 @@ namespace TON
|
||||
public void OnClickSkillSlot()
|
||||
{
|
||||
GameObject selectedSlotGameObject = EventSystem.current.currentSelectedGameObject;
|
||||
SkillSettingUI_SkillSlot selectedSlot = selectedSlotGameObject.GetComponent<SkillSettingUI_SkillSlot>();
|
||||
SkillSettingSlot selectedSlot = selectedSlotGameObject.GetComponent<SkillSettingSlot>();
|
||||
|
||||
selectedSlotIndex = selectedSlot.SelectedSlot();
|
||||
for (int i = 0; i < 3; i++)
|
||||
@@ -201,7 +201,7 @@ namespace TON
|
||||
IEnumerator CloseButtonDelay()
|
||||
{
|
||||
yield return new WaitForSeconds(0.2f); // 0.2초 대기
|
||||
|
||||
|
||||
UIManager.Hide<SkillSettingUI>(UIList.SkillSettingUI);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class SkillSettingUI_SkillSlot : MonoBehaviour
|
||||
{
|
||||
public GameObject skillImage;
|
||||
public GameObject lockerImage;
|
||||
public GameObject selectedState;
|
||||
|
||||
private int slotIndex;
|
||||
|
||||
public void Initalize(string skillId, int index)
|
||||
{
|
||||
slotIndex = index;
|
||||
// 스킬 이미지 세팅하기
|
||||
if (skillId != null) // 스킬 슬롯에 스킬이 지정된 경우
|
||||
{
|
||||
// out 으로 받을 변수 초기화
|
||||
Sprite loadedSkillImage = null;
|
||||
Assert.IsTrue(AssetManager.Singleton.LoadSkillIcon(skillId, out loadedSkillImage));
|
||||
skillImage.SetActive(true);
|
||||
skillImage.GetComponent<Image>().sprite = loadedSkillImage;
|
||||
}
|
||||
|
||||
lockerImage.SetActive(false);
|
||||
}
|
||||
|
||||
public int SelectedSlot()
|
||||
{
|
||||
selectedState.SetActive(true);
|
||||
return slotIndex;
|
||||
}
|
||||
|
||||
public void UnselectedSlot()
|
||||
{
|
||||
selectedState.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19db9b1bf85c67042afc28005a6af101
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user