You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using MS;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
|
|
[ExecuteInEditMode]
|
|
public class LevelGroupButton : MonoBehaviour
|
|
{
|
|
public LevelGroup levelGroup;
|
|
|
|
// Use TMP_Text instead of Text
|
|
public TMP_Text TitleLbl;
|
|
public TMP_Text LevelCompletdLbl;
|
|
public GameObject AwardGoldImage;
|
|
public int TotalLevelsCompleted;
|
|
|
|
private void Start()
|
|
{
|
|
UpdateUI();
|
|
GetComponent<Button>().onClick.AddListener(delegate
|
|
{
|
|
HomeScene.instance.ShowDetailLevel(this);
|
|
HomeScene.instance.PlayButton();
|
|
GameObject.FindWithTag("LevelGroupPopup").GetComponent<Popup>().Close();
|
|
});
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
UpdateUI(); // If more logic is needed, add it here
|
|
}
|
|
|
|
[ContextMenu("UpdateUI")]
|
|
public void UpdateUI()
|
|
{
|
|
base.name = levelGroup.LevelGroupName;
|
|
TitleLbl.text = base.name.ToUpper();
|
|
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
|
|
|
|
// Decide between SetActive or using _2dxFX_GrayScale
|
|
if (levelGroup.CompletedLevel >= 5)
|
|
{
|
|
AwardGoldImage.SetActive(true); // Show award if completed levels >= 5
|
|
}
|
|
else
|
|
{
|
|
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
|
|
}
|
|
|
|
TotalLevelsCompleted = levelGroup.CompletedLevel;
|
|
}
|
|
} |