-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkipPuzzleButton.cs
52 lines (48 loc) · 1.2 KB
/
SkipPuzzleButton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using UnityEngine;
namespace Puzzleskip
{
internal class SkipPuzzleButton : MonoBehaviour
{
private UILabel _label;
private bool _skipEnabled;
private string _originalText;
private float _buttonDownSeconds = 0;
public void Awake()
{
_label = this.gameObject.GetComponentInChildren<UILabel>();
_originalText = _label.text;
}
public void Update()
{
if (Input.GetMouseButton(1))
{
_buttonDownSeconds += Time.deltaTime;
}
else
{
_buttonDownSeconds = 0;
}
if (_buttonDownSeconds > 3)
{
SkipEnabled = !SkipEnabled;
_buttonDownSeconds = 0;
}
}
public bool SkipEnabled
{
get { return _skipEnabled; }
set
{
_skipEnabled = value;
if (_skipEnabled)
{
_label.text = "Skip";
}
else
{
_label.text = _originalText;
}
}
}
}
}