You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
586 B
35 lines
586 B
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class ButtonTimeLimit : MonoBehaviour |
|
{ |
|
Button btn; |
|
public float time = 5f; |
|
|
|
void Start() |
|
{ |
|
btn = GetComponent<Button>(); |
|
|
|
OnDisabled(); |
|
} |
|
public void OnClick() |
|
{ |
|
OnDisabled(); |
|
} |
|
|
|
void Activation() |
|
{ |
|
btn.interactable = true; |
|
} |
|
void OnDisabled() |
|
{ |
|
btn.interactable = false; |
|
Invoke("Activation", time); |
|
} |
|
private void OnDestroy() |
|
{ |
|
CancelInvoke(); |
|
} |
|
}
|
|
|