-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.cs
37 lines (30 loc) · 940 Bytes
/
controller.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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using SocketIO;
public class controller : MonoBehaviour {
private GameObject player;
string gamedata="";
void Start () {
GameObject go = GameObject.Find("SocketIO");
player = GameObject.Find ("player");
SocketIOComponent socket= go.GetComponent<SocketIOComponent>();
socket.On ("datarec",(SocketIOEvent obj) => {
//Debug.Log(obj.data);
Debug.Log(obj.data.ToString().Substring(9,3));
gamedata=obj.data.ToString().Substring(9,3);
player.transform.Rotate (0,float.Parse(gamedata), 0);
});
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
if (GUI.Button (new Rect (10, 70, 50, 30), "Click")) {
Debug.Log ("Clicked the button with text");
GameObject go = GameObject.Find("SocketIO");
SocketIOComponent socket= go.GetComponent<SocketIOComponent>();
//socket.Emit ("disconnect");
}
}
}