-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button cooldown to prevent spam undo/load (#6)
- Loading branch information
1 parent
2a8ce0f
commit 350929b
Showing
3 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace DanielLochner.Assets | ||
{ | ||
public class ButtonCooldown : MonoBehaviour | ||
{ | ||
#region Fields | ||
[SerializeField] private float cooldown; | ||
|
||
private Button button; | ||
#endregion | ||
|
||
#region Methods | ||
private void Awake() | ||
{ | ||
button = GetComponent<Button>(); | ||
button.onClick.AddListener(OnButtonClicked); | ||
} | ||
|
||
private void OnButtonClicked() | ||
{ | ||
button.interactable = false; | ||
|
||
this.Invoke(delegate | ||
{ | ||
button.interactable = true; | ||
}, | ||
cooldown); | ||
} | ||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.