-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript_SparkAR
130 lines (61 loc) · 2 KB
/
Script_SparkAR
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const Scene = require('Scene');
const NativeUI = require('NativeUI');
const Textures = require('Textures');
const Audio = require('Audio');
// First, we create a Promise and load all the assets we need for our scene
Promise.all([
// Loading Textures for the buttons
Textures.findFirst('texture0'),
Textures.findFirst('texture1'),
Textures.findFirst('texture2'),
Scene.root.findFirst('nullObject0'),
Scene.root.findFirst('nullObject1'),
Scene.root.findFirst('nullObject2'),
// we can start using our assets and creating the NativeUI Picker
]).then(function(results){
// First, we set the buttons for the NativeUI Picker
const button1 = results[0];
const button2 = results[1];
const button3 = results[2];
// Next, we set the Null Objacts for the switch
const Obj0 = results[3];
const Obj1 = results[4];
const Obj2 = results[5];
// Now, we can finally start building the NativeUI Picker
const configuration = {
selectedIndex: 0,
// These are the image textures to use as the buttons in the NativeUI Picker
items: [
{image_texture: button1},
{image_texture: button2},
{image_texture: button3}
]
};
// Create the NativeUI Picker
const picker = NativeUI.picker;
picker.configure(configuration);
picker.visible = true;
// This is a monitor that watches for the picker to be used.
picker.selectedIndex.monitor().subscribe(function(val) {
switch(val.newValue) {
case 0: {
Obj0.hidden = false;
Obj1.hidden = true;
Obj2.hidden = true;
break;
}
case 1: {
Obj0.hidden = true;
Obj1.hidden = false;
Obj2.hidden = true;
break;
}
case 2: {
Obj0.hidden = true;
Obj1.hidden = true;
Obj2.hidden = false;
break;
}
}
});
});