-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonController.cs
115 lines (110 loc) · 2.97 KB
/
ButtonController.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ButtonController : MonoBehaviour, IEventSystemHandler
{
public GameObject fps;
public float maxSpeed = 10f;
bool LeftButtonHeld = false;
bool RightButtonHeld = false;
bool ForwardButtonHeld = false;
bool BackwardButtonHeld = false;
bool RotationButtonHeld = false;
bool RotationBackwardsButtonHeld = false;
bool upButtonHeld = false;
bool downButtonHeld = false;
bool copyButtonHeld = false;
public void pressedLeft(BaseEventData eventData)
{
LeftButtonHeld = true;
}
public void pressedRight(BaseEventData eventData)
{
RightButtonHeld = true;
}
public void pressedForward(BaseEventData eventData)
{
ForwardButtonHeld = true;
}
public void pressedBackward(BaseEventData eventData)
{
BackwardButtonHeld = true;
}
public void pressedRotate(BaseEventData eventData)
{
RotationButtonHeld = true;
}
public void pressedRotateBack(BaseEventData eventData)
{
RotationBackwardsButtonHeld = true;
}
public void pressedUp(BaseEventData eventData)
{
upButtonHeld = true;
}
public void pressedDown(BaseEventData eventData)
{
downButtonHeld = true;
}
public void pressedCopy(BaseEventData eventData)
{
copyButtonHeld = true;
}
public void notpressed(BaseEventData eventData)
{
LeftButtonHeld = false;
RightButtonHeld = false;
ForwardButtonHeld = false;
BackwardButtonHeld = false;
RotationButtonHeld = false;
RotationBackwardsButtonHeld = false;
upButtonHeld = false;
downButtonHeld = false;
copyButtonHeld = false;
}
void Start()
{
//fps = GameObject.FindWithTag("FPS");
}
public void Update()
{
if (LeftButtonHeld)
{
fps.transform.Translate(-0.1f, 0, 0);
}
else if (RightButtonHeld)
{
fps.transform.Translate(0.1f, 0, 0);
}
else if (ForwardButtonHeld)
{
fps.transform.Translate(0, 0, 0.1f);
}
else if (BackwardButtonHeld)
{
fps.transform.Translate(0, 0, -0.1f);
}
else if (RotationButtonHeld)
{
fps.transform.Rotate((new Vector3(0, -6, 0)) * Time.deltaTime, -1, Space.World);
}
else if (RotationBackwardsButtonHeld)
{
fps.transform.Rotate((new Vector3(0, -6, 0)) * Time.deltaTime, 1, Space.World);
}
else if (upButtonHeld)
{
fps.transform.Translate(0, 0.1f, 0);
}
else if (downButtonHeld)
{
fps.transform.Translate(0, -0.1f, 0);
}
else if (copyButtonHeld)
{
//fps.SendMessage("copyAcross");
//GenerateAtom.Instance.copyAcross();
}
}
}