-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRotate.cs
53 lines (46 loc) · 1.25 KB
/
Rotate.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 System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
private bool canRotate = true;
// Use this for initialization
void Awake()
{
UnityMessageManager.Instance.OnRNMessage += onMessage;
}
void onDestroy()
{
UnityMessageManager.Instance.OnRNMessage -= onMessage;
}
void onMessage(MessageHandler message)
{
var data = message.getData<string>();
Debug.Log("onMessage:" + data);
canRotate = !canRotate;
UnityMessageManager.Instance.SendMessageToRN("Now it is " + (canRotate ? "": "not ") + "rotating");
message.send(new { CallbackTest = "I am Unity callback" });
}
void OnMouseDown()
{
Debug.Log("click");
UnityMessageManager.Instance.SendMessageToRN(new UnityMessage()
{
name = "click",
callBack = (data) =>
{
Debug.Log("onClickCallBack:" + data);
}
});
}
// Update is called once per frame
void Update()
{
if (!canRotate)
{
return;
}
var delta = 30 * Time.deltaTime;
transform.localRotation *= Quaternion.Euler(delta, delta, delta);
}
}