-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSpinCube.cs
101 lines (86 loc) · 2.04 KB
/
SpinCube.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
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using RNUnity;
public class SpinCube : MonoBehaviour
{
bool _rotate;
bool _scale;
public Vector3 RotateAmount;
// Start is called before the first frame update
void Start()
{
_rotate = true;
_scale = false;
}
// Update is called once per frame
void Update()
{
if (_rotate)
transform.Rotate(RotateAmount);
}
void setColor(string input)
{
Color color;
if (ColorUtility.TryParseHtmlString(input, out color))
GetComponent<Renderer>().material.color = color;
}
void toggleRotate()
{
_rotate = !_rotate;
}
void toggleScale()
{
_scale = !_scale;
transform.localScale *= _scale ? 2.0f : 0.5f;
}
void OnMouseDown()
{
RNBridge.SendMessage("click!");
toggleScale();
}
// Call the following methods from your RN app
void toggleRotateRN(object param)
{
toggleRotate();
RNPromise
.Begin(param)
.Resolve(_rotate);
}
void getAccountRN(object param)
{
RNPromise
.Begin(param)
.Resolve(new Account
{
Email = "[email protected]",
Active = true,
CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc),
Roles = new List<string>
{
"User",
"Admin"
}
});
}
void failRN(object param)
{
RNPromise
.Begin(param)
.Reject("This doesn't work");
}
void setColorRN(object param)
{
var promise = RNPromise<string>.Begin(param);
setColor(promise.input);
promise.Resolve();
}
}
public class Account
{
public string Email { get; set; }
public bool Active { get; set; }
public DateTime CreatedDate { get; set; }
public IList<string> Roles { get; set; }
}