質問編集履歴
5
写真の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-

|
1
|
+

|
2
2
|
ボタンがクリックされたら、csvに書き込むようにしたいのですができなくて困っています。
|
3
3
|
ここ↓ と2か所書いた場所でできると思っていたのですが、なにがおかしいでしょうか?それとも、unityのボタンのほうに原因があるのでしょうか?
|
4
4
|
|
4
プログラムの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -122,4 +122,121 @@
|
|
122
122
|
}
|
123
123
|
}
|
124
124
|
}
|
125
|
+
```
|
126
|
+
|
127
|
+
```c#
|
128
|
+
using System.Collections;
|
129
|
+
using System.Collections.Generic;
|
130
|
+
using UnityEngine;
|
131
|
+
using Enflux.SDK.Core;
|
132
|
+
using UnityEngine.UI;
|
133
|
+
using System;
|
134
|
+
using System.Linq;
|
135
|
+
using Enflux.Common.DataTypes;
|
136
|
+
using Enflux.SDK.Core.Devices;
|
137
|
+
using Enflux.SDK.DataTypes;
|
138
|
+
using Enflux.SDK.Extensions;
|
139
|
+
using Enflux.SDK.Utils;
|
140
|
+
using Enflux.Shim.Utils;
|
141
|
+
using System.IO;
|
142
|
+
|
143
|
+
public class math : MonoBehaviour
|
144
|
+
{
|
145
|
+
// Assign these in the editor.
|
146
|
+
public EnfluxManager EnfluxManager;
|
147
|
+
public Humanoid Humanoid;
|
148
|
+
// Retrieve limb orientations as Unity local space quaternions.
|
149
|
+
private void GetLocalSpaceOrientations()
|
150
|
+
{
|
151
|
+
var chest = Humanoid.LocalOrientations.Chest.Orientation;
|
152
|
+
var leftUpperArm = Humanoid.LocalOrientations.LeftUpperArm.Orientation;
|
153
|
+
var leftLowerArm = Humanoid.LocalOrientations.LeftLowerArm.Orientation;
|
154
|
+
var rightUpperArm = Humanoid.LocalOrientations.RightUpperArm.Orientation;
|
155
|
+
var rightLowerArm = Humanoid.LocalOrientations.RightLowerArm.Orientation;
|
156
|
+
var pelvis = Humanoid.LocalOrientations.Pelvis.Orientation;
|
157
|
+
var leftUpperLeg = Humanoid.LocalOrientations.LeftUpperLeg.Orientation;
|
158
|
+
var leftLowerLeg = Humanoid.LocalOrientations.LeftLowerLeg.Orientation;
|
159
|
+
var rightUpperLeg = Humanoid.LocalOrientations.RightUpperLeg.Orientation;
|
160
|
+
var rightLowerLeg = Humanoid.LocalOrientations.RightLowerLeg.Orientation;
|
161
|
+
}
|
162
|
+
|
163
|
+
// Retrieve limb orientations as real world NED (North-East-Down) space quaternions.
|
164
|
+
private string GetNedSpaceOrientations()
|
165
|
+
{
|
166
|
+
var chest = EnfluxManager.NedOrientations.Chest.Orientation;
|
167
|
+
var leftUpperArm = EnfluxManager.NedOrientations.LeftUpperArm.Orientation;
|
168
|
+
var leftLowerArm = EnfluxManager.NedOrientations.LeftLowerArm.Orientation;
|
169
|
+
var rightUpperArm = EnfluxManager.NedOrientations.RightUpperArm.Orientation;
|
170
|
+
var rightLowerArm = EnfluxManager.NedOrientations.RightLowerArm.Orientation;
|
171
|
+
var pelvis = EnfluxManager.NedOrientations.Pelvis.Orientation;
|
172
|
+
var leftUpperLeg = EnfluxManager.NedOrientations.LeftUpperLeg.Orientation;
|
173
|
+
var leftLowerLeg = EnfluxManager.NedOrientations.LeftLowerLeg.Orientation;
|
174
|
+
var rightUpperLeg = EnfluxManager.NedOrientations.RightUpperLeg.Orientation;
|
175
|
+
var rightLowerLeg = EnfluxManager.NedOrientations.RightLowerLeg.Orientation;
|
176
|
+
|
177
|
+
|
178
|
+
return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm +
|
179
|
+
"\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg + "\n\n";
|
180
|
+
}
|
181
|
+
|
182
|
+
//時間
|
183
|
+
void FindSundayOfTheWeek()
|
184
|
+
{
|
185
|
+
System.DateTime work = System.DateTime.Now;
|
186
|
+
Debug.Log(work.ToString());
|
187
|
+
}
|
188
|
+
|
189
|
+
//書き出し準備
|
190
|
+
private int i = 1;
|
191
|
+
StreamWriter sw;
|
192
|
+
FileInfo fi;
|
193
|
+
|
194
|
+
int x = 0;
|
195
|
+
public void OnClick()
|
196
|
+
{
|
197
|
+
x++;
|
198
|
+
Debug.Log(x);
|
199
|
+
Debug.Log("Button click!");
|
200
|
+
}
|
201
|
+
|
202
|
+
void Start()
|
203
|
+
{
|
204
|
+
|
205
|
+
FindSundayOfTheWeek();
|
206
|
+
|
207
|
+
//ファイル準備
|
208
|
+
fi = new FileInfo(Application.dataPath + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
|
209
|
+
sw = fi.AppendText();
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
private float timeleft;
|
214
|
+
int log;
|
215
|
+
|
216
|
+
void Update()
|
217
|
+
{
|
218
|
+
if (i > 10000)
|
219
|
+
{
|
220
|
+
sw.Close();
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
timeleft -= Time.deltaTime;
|
224
|
+
if (timeleft <= 0.0)
|
225
|
+
{
|
226
|
+
timeleft = 1.0f;
|
227
|
+
|
228
|
+
//処理
|
229
|
+
Debug.Log(GetNedSpaceOrientations());
|
230
|
+
this.GetComponent<Text>().text = GetNedSpaceOrientations();
|
231
|
+
|
232
|
+
//書き出す
|
233
|
+
|
234
|
+
sw.WriteLine(GetNedSpaceOrientations());
|
235
|
+
sw.Flush();
|
236
|
+
|
237
|
+
i++;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
125
242
|
```
|
3
プログラムの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
```c#
|
7
|
-
|
8
7
|
using System.Collections;
|
9
8
|
using System.Collections.Generic;
|
10
9
|
using UnityEngine;
|
@@ -55,9 +54,9 @@
|
|
55
54
|
var rightUpperLeg = EnfluxManager.NedOrientations.RightUpperLeg.Orientation;
|
56
55
|
var rightLowerLeg = EnfluxManager.NedOrientations.RightLowerLeg.Orientation;
|
57
56
|
|
58
|
-
|
57
|
+
|
59
|
-
return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm +
|
58
|
+
return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm +
|
60
|
-
"\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg;
|
59
|
+
"\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg + "\n\n";
|
61
60
|
}
|
62
61
|
|
63
62
|
//時間
|
@@ -68,12 +67,11 @@
|
|
68
67
|
}
|
69
68
|
|
70
69
|
//書き出し準備
|
71
|
-
private GameObject cube;
|
72
70
|
private int i = 1;
|
73
71
|
StreamWriter sw;
|
74
72
|
FileInfo fi;
|
75
73
|
|
76
|
-
|
74
|
+
|
77
75
|
bool aa;
|
78
76
|
public void Push()
|
79
77
|
{
|
@@ -89,7 +87,6 @@
|
|
89
87
|
|
90
88
|
FindSundayOfTheWeek();
|
91
89
|
|
92
|
-
cube = GameObject.Find("Cube");
|
93
90
|
//ファイル準備
|
94
91
|
fi = new FileInfo(Application.dataPath + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
|
95
92
|
sw = fi.AppendText();
|
@@ -99,35 +96,29 @@
|
|
99
96
|
private float timeleft;
|
100
97
|
int log;
|
101
98
|
|
102
|
-
void Update()
|
99
|
+
void Update()
|
103
|
-
{
|
100
|
+
{
|
104
|
-
|
101
|
+
|
105
|
-
if(
|
102
|
+
if (i > 10000)
|
106
103
|
{
|
107
|
-
Debug.Log(GetNedSpaceOrientations());
|
108
|
-
if (i > 10000)
|
109
|
-
{
|
110
104
|
sw.Close();
|
111
105
|
return;
|
112
|
-
|
106
|
+
}
|
113
107
|
timeleft -= Time.deltaTime;
|
114
|
-
|
108
|
+
if (timeleft <= 0.0)
|
115
|
-
|
109
|
+
{
|
116
|
-
|
110
|
+
timeleft = 1.0f;
|
117
111
|
|
118
|
-
|
112
|
+
//処理
|
119
|
-
|
113
|
+
Debug.Log(GetNedSpaceOrientations());
|
120
|
-
|
114
|
+
this.GetComponent<Text>().text = GetNedSpaceOrientations();
|
121
115
|
|
122
|
-
|
116
|
+
//書き出す
|
123
117
|
|
124
|
-
|
118
|
+
sw.WriteLine(GetNedSpaceOrientations());
|
125
|
-
|
119
|
+
sw.Flush();
|
126
120
|
|
127
|
-
|
121
|
+
i++;
|
128
|
-
}
|
129
|
-
|
130
|
-
}
|
131
122
|
}
|
132
123
|
}
|
133
124
|
}
|
2
マークダウン
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|

|
2
2
|
ボタンがクリックされたら、csvに書き込むようにしたいのですができなくて困っています。
|
3
3
|
ここ↓ と2か所書いた場所でできると思っていたのですが、なにがおかしいでしょうか?それとも、unityのボタンのほうに原因があるのでしょうか?
|
4
|
-
----------------------------------------------------------
|
5
4
|
|
5
|
+
|
6
|
+
```c#
|
7
|
+
|
6
8
|
using System.Collections;
|
7
9
|
using System.Collections.Generic;
|
8
10
|
using UnityEngine;
|
@@ -129,5 +131,4 @@
|
|
129
131
|
}
|
130
132
|
}
|
131
133
|
}
|
132
|
-
|
133
|
-
|
134
|
+
```
|
1
写真の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+

|
1
2
|
ボタンがクリックされたら、csvに書き込むようにしたいのですができなくて困っています。
|
2
3
|
ここ↓ と2か所書いた場所でできると思っていたのですが、なにがおかしいでしょうか?それとも、unityのボタンのほうに原因があるのでしょうか?
|
3
4
|
----------------------------------------------------------
|