-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopbtn.cs
53 lines (48 loc) · 1.2 KB
/
stopbtn.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
using Sharp7;
using UnityEngine;
using UnityEngine.UI;
public class stopbtn : MonoBehaviour
{
[SerializeField] string machineName;
ConnectToPLC machineComms;
[SerializeField] string signal_name;
[SerializeField] short iiot_access_mode = 1;
Button button;
[SerializeField] public bool boolValue;
bool valueChanged;
//Image image;
// Color bgCol;
string value;
void Start()
{
button = GetComponent<Button>();
machineComms = GameObject.Find(machineName).GetComponent<ConnectToPLC>();
button.onClick.AddListener(IIoTWrite);
//image = GetComponent<Image>();
//bgCol = image.color;
}
void Update()
{
/*if (boolValue)
{
var temp = image.color;
temp.a = 1f;
image.color = temp;
}
else
{
var temp = image.color;
temp.a = 0.6f;
image.color = temp;
}*/
}
void IIoTWrite()
{
boolValue = !boolValue;
machineComms.PLCWrite(signal_name, boolValue.ToString());
}
public void SetToFalse()
{
boolValue = false;
}
}