Files
MinFt/Client/Assets/Scripts/UIRedPoint/UIRedPoint.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

99 lines
2.4 KiB
C#

using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UIRedPoint : MonoBehaviour, IUIRedPoint
{
public string key;
public Image image;
public GameObject redPoint;
public GameObject redpoint_big;
public TMP_Text text_redpoint_big;
private void Awake()
{
if (string.IsNullOrEmpty(key))
{
return;
}
RedPointManager.Instance.AddRedPoint(key, this);
}
public void SetKey(string _key)
{
if (!string.IsNullOrEmpty(key))
{
RedPointManager.Instance.RemoveRedPoint(key);
}
key = _key;
RedPointManager.Instance.AddRedPoint(key, this);
if (redPoint != null)
{
redPoint.SetActive(RedPointManager.Instance.GetRedPointState(key));
}
if (image != null)
{
image.enabled = RedPointManager.Instance.GetRedPointState(key);
}
}
private void OnEnable()
{
if (string.IsNullOrEmpty(key))
{
return;
}
SetRedPointState(RedPointManager.Instance.GetRedPointState(key));
}
public void SetRedPointState(bool state)
{
if (string.IsNullOrEmpty(key))
{
return;
}
if (redpoint_big != null && text_redpoint_big != null)
{
if (!state)
{
redpoint_big.SetActive(false);
}
else
{
int count = RedPointManager.Instance.GetRedPointCount(key);
if (count > 1)
{
redpoint_big.SetActive(true);
if (count > 99)
{
text_redpoint_big.text = "99+";
}
else
{
text_redpoint_big.text = count.ToString();
}
state = false;
}
else
{
redpoint_big.SetActive(false);
}
}
}
if (redPoint != null)
{
redPoint.SetActive(state);
}
if (image != null)
{
image.enabled = state;
}
}
private void OnDestroy()
{
if (string.IsNullOrEmpty(key))
{
return;
}
RedPointManager.Instance.RemoveRedPoint(key);
}
}