public class MyButton : MonoBehaviour
{
public bool isClick;//是否点击
public float tempTime = 0;//计时器
public Button Btn;//按钮
void Awake()
{
Btn.onClick.AddListener(OnClick);//注册按钮事件
}
void Update()
{
if (isClick)//如果被点击
{
tempTime+= Time.deltaTime;
if (tempTime> 2)
{
tempTime= 0;
Btn.enable = true;
isClick = false;
}
}
}
private void OnClick()
{
isClick = true;
Btn.enable= false;
}
}
网友评论