在首次触发后,按钮不再起作用
使用Coroutine实现按钮的首次触发操作。
具体代码示例:
public class ButtonController : MonoBehaviour
{
private bool hasBeenClicked = false;
private IEnumerator ButtonCoroutine()
{
// 首次点击
hasBeenClicked = true;
Debug.Log("Button clicked for the first time");
// 暂停协程一段时间
yield return new WaitForSeconds(1f);
// 恢复按钮状态
Debug.Log("Button re-enabled");
GetComponent