using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RewardMenu : MonoBehaviour
{
[SerializeField] Button[] rewardBtns;
[SerializeField] Reward[] rewardScripts;
[SerializeField] Button claimBtn;
private void Start()
{
Init();
for(int i=0; i<rewardBtns.Length; i++)
{
int idx = i;
rewardBtns[idx].onClick.AddListener(() => {
for(int j = 0; j<rewardBtns.Length; j++)
{
int idx2 = j;
rewardScripts[idx2].focus.gameObject.SetActive(false);
}
rewardScripts[idx].focus.gameObject.SetActive(true);
});
}
claimBtn.onClick.AddListener(() => {
for(int i = 0; i< rewardScripts.Length; i++)
{
int idx3 = i;
rewardScripts[idx3].text.gameObject.SetActive(true);
}
});
}
private void Init()
{
for(int i = 0; i < rewardScripts.Length; i++)
{
rewardScripts[i].focus.gameObject.SetActive(false);
rewardScripts[i].text.gameObject.SetActive(false);
}
}
}
2. RewardMenu.cs
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class Reward : MonoBehaviour
{
public Image focus;
public TMP_Text text;
}
3. Reward.cs
'산대특 > 게임 UIUX프로그래밍' 카테고리의 다른 글
[LearnUGUI] 팝업을 통한 이름 변경해보기 (0) | 2024.02.07 |
---|---|
[LearnUGUI] 로딩바 만들기 (0) | 2024.02.07 |
[LearnUGUI] 체크박스 버튼 ON/OFF 구현 (0) | 2024.02.06 |
[LearnUGUI] TabMenu 및 TabMenu 전환 구현 (0) | 2024.02.06 |
[LearnUGUI] ON/OFF 토글 버튼 만들기 (0) | 2024.02.06 |