-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.cs
More file actions
79 lines (60 loc) · 1.66 KB
/
Copy pathButton.cs
File metadata and controls
79 lines (60 loc) · 1.66 KB
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
using Godot;
using Senstate.CSharp_Client;
using Senstate.NetStandard;
using System;
public class Button : Godot.Button
{
private int counter = 0;
private bool toggeled = false;
private Watcher stringWatcher;
private Watcher countWatcher;
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
var webSocket = new NetStandardWebSocketImplementation();
webSocket.ExceptionThrown += (sender, e) => // Optional if you want to catch Connection issues
{
throw e.Exception;
};
SenstateContext.SerializerInstance = new NetStandardJsonNetImplementation();
SenstateContext.WebSocketInstance = webSocket;
SenstateContext.RegisterApp("Godot");
stringWatcher = new Watcher(
new WatcherMeta
{
Tag = "Text label",
Type = WatcherType.String, // or Number / Json
}
);
countWatcher = new Watcher(
new WatcherMeta
{
Tag = "Click Counter",
Type = WatcherType.Number, // or Number / Json
}
);
}
// // Called every frame. 'delta' is the elapsed time since the previous frame.
// public override void _Process(float delta)
// {
//
// }
private void _on_Button_pressed()
{
toggeled = !toggeled;
updateLabel();
// Replace with function body.
}
private void updateLabel() {
var parent = GetParent();
var label = parent.GetNode<Label>("Label");
label.Text = toggeled ? "Toggled" : "Not";
stringWatcher.SendData(label.Text);
var counterLabel = parent.GetNode<Label>("Counter");
counterLabel.Text = $"{counter++}";
countWatcher.SendData(counter);
}
}