This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
usingSystem.Collections;
usingSystem.Collections.Generic;
usingUnityEngine;
usingUnityEngine.UI;
publicclassCardCounter:MonoBehaviour
{
publicTextcounterText;
privateintcounter=0;
publicboolSetCounter(int_value)
{
counter+=_value;
OnCounterChange();
if(counter==0)
{
Destroy(gameObject);
returnfalse;
}
returntrue;
}
privatevoidOnCounterChange()//给卡牌数量文本字段赋值
{
//测试是否拿到counter数据,这里成功
//Debug.Log("counter:"+counter.ToString());
if(counterText!=null)// 添加空值检查
{
counterText.text=counter.ToString();
}
else
{
Debug.LogError("counterText is null, please assign a Text component in the inspector.");