質問編集履歴

3

質問内容を具体的に修正

2018/12/17 07:41

投稿

shiro16
shiro16

スコア15

test CHANGED
@@ -1 +1 @@
1
- No MonoBehaviour scripts in the file,or their names do not match the file name.のエラー対処法につ
1
+ KinectV2を使って Unityちゃんを動かした
test CHANGED
@@ -10,43 +10,361 @@
10
10
 
11
11
  kinect for windows : [リンク](https://www.microsoft.com/en-us/download/details.aspx?id=44561) からダウンロードしてきたものをインポートする
12
12
 
13
- ことはできたのですが、スクリプトに以下のようなエラーが動きせん
14
-
15
-
16
-
17
- **No MonoBehaviour scripts in the file,
18
-
19
- or their names do not match the file name.**
20
-
21
-
22
-
23
- ダウンロードしたものであることと、
24
-
25
- 名前が間違っていないかは確認しました。
26
-
27
-
28
-
29
-
30
-
31
- kinect viewをドラッグアンドドロップしてコピーした際に
32
-
33
- 出てくるはずの unity4から5へのAPI更新の自動変更を行うダイアログが
34
-
35
- 表示されなかったのも、エラーが起こった要因でしょうか?
36
-
37
-
38
-
39
- unity2018.2.15 64bitを使用して作っていたときは
40
-
41
- ここではつまらなかったのですが、アップデートをしてunity2018.2.19に
42
-
43
- するとエラーが出た気がしました。
44
-
45
-
46
-
47
- しかし、古いほうで開くと同じエラーが出るようになってしまいました。
48
-
49
-
13
+ ことはできたのですが、KinectAvatarのスクリプトエラーがたくさんでいます
14
+
15
+
16
+
17
+ ```ここに言語を入力
18
+
19
+ using UnityEngine;
20
+
21
+ using System.Collections;
22
+
23
+ using Windows.Kinect;
24
+
25
+ using System.Collections.Generic;
26
+
27
+ using System.Linq;
28
+
29
+
30
+
31
+ public class KinectAvatar : MonoBehaviour {
32
+
33
+
34
+
35
+ public bool IsMirror = true;
36
+
37
+
38
+
39
+ public BodySourceManager _BodyManager;
40
+
41
+ public GameObject _UnityChan;
42
+
43
+
44
+
45
+ public GameObject Ref;
46
+
47
+ public GameObject Hips;
48
+
49
+ public GameObject LeftUpLeg;
50
+
51
+ public GameObject LeftLeg;
52
+
53
+ public GameObject RightUpLeg;
54
+
55
+ public GameObject RightLeg;
56
+
57
+ public GameObject Spine1;
58
+
59
+ public GameObject Spine2;
60
+
61
+ public GameObject LeftShoulder;
62
+
63
+ public GameObject LeftArm;
64
+
65
+ public GameObject LeftForeArm;
66
+
67
+ public GameObject LeftHand;
68
+
69
+ public GameObject RightShoulder;
70
+
71
+ public GameObject RightArm;
72
+
73
+ public GameObject RightForeArm;
74
+
75
+ public GameObject RightHand;
76
+
77
+ public GameObject Neck;
78
+
79
+ public GameObject Head;
80
+
81
+
82
+
83
+
84
+
85
+ // Use this for initialization
86
+
87
+ void Start () {
88
+
89
+ Ref = _UnityChan.transform.FindChild( "Character1_Reference" ).gameObject;
90
+
91
+
92
+
93
+ Hips = Ref.gameObject.transform.FindChild( "Character1_Hips" ).gameObject;
94
+
95
+ LeftUpLeg = Hips.transform.FindChild( "Character1_LeftUpLeg" ).gameObject;
96
+
97
+ LeftLeg = LeftUpLeg.transform.FindChild( "Character1_LeftLeg" ).gameObject;
98
+
99
+ RightUpLeg = Hips.transform.FindChild( "Character1_RightUpLeg" ).gameObject;
100
+
101
+ RightLeg = RightUpLeg.transform.FindChild( "Character1_RightLeg" ).gameObject;
102
+
103
+ Spine1 = Hips.transform.FindChild( "Character1_Spine" ).
104
+
105
+ gameObject.transform.FindChild( "Character1_Spine1" ).gameObject;
106
+
107
+ Spine2 = Spine1.transform.FindChild( "Character1_Spine2" ).gameObject;
108
+
109
+ LeftShoulder = Spine2.transform.FindChild( "Character1_LeftShoulder" ).gameObject;
110
+
111
+ LeftArm = LeftShoulder.transform.FindChild( "Character1_LeftArm" ).gameObject;
112
+
113
+ LeftForeArm = LeftArm.transform.FindChild( "Character1_LeftForeArm" ).gameObject;
114
+
115
+ LeftHand = LeftForeArm.transform.FindChild( "Character1_LeftHand" ).gameObject;
116
+
117
+ RightShoulder = Spine2.transform.FindChild( "Character1_RightShoulder" ).gameObject;
118
+
119
+ RightArm = RightShoulder.transform.FindChild( "Character1_RightArm" ).gameObject;
120
+
121
+ RightForeArm = RightArm.transform.FindChild( "Character1_RightForeArm" ).gameObject;
122
+
123
+ RightHand = RightForeArm.transform.FindChild( "Character1_RightHand" ).gameObject;
124
+
125
+ Neck = Spine2.transform.FindChild( "Character1_Neck" ).gameObject;
126
+
127
+ Head = Neck.transform.FindChild( "Character1_Head" ).gameObject;
128
+
129
+ }
130
+
131
+
132
+
133
+ // Update is called once per frame
134
+
135
+ void Update () {
136
+
137
+ if ( _BodyManager == null ) {
138
+
139
+ Debug.Log( "_BodyManager == null" );
140
+
141
+ return;
142
+
143
+ }
144
+
145
+
146
+
147
+ // Bodyデータを取得する
148
+
149
+ var data = _BodyManager.GetData();
150
+
151
+ if ( data == null ) {
152
+
153
+ return;
154
+
155
+ }
156
+
157
+
158
+
159
+ // 最初に追跡している人を取得する
160
+
161
+ var body = data.FirstOrDefault( b => b.IsTracked );
162
+
163
+ if ( body == null ) {
164
+
165
+ return;
166
+
167
+ }
168
+
169
+
170
+
171
+ // 床の傾きを取得する
172
+
173
+ var floorPlane = _BodyManager.FloorClipPlane;
174
+
175
+ var comp = Quaternion.FromToRotation(
176
+
177
+ new Vector3( floorPlane.X, floorPlane.Y, floorPlane.Z ), Vector3.up );
178
+
179
+
180
+
181
+ // 関節の回転を取得する
182
+
183
+ var joints = body.JointOrientations;
184
+
185
+
186
+
187
+ Quaternion SpineBase;
188
+
189
+ Quaternion SpineMid;
190
+
191
+ Quaternion SpineShoulder;
192
+
193
+ Quaternion ShoulderLeft;
194
+
195
+ Quaternion ShoulderRight;
196
+
197
+ Quaternion ElbowLeft;
198
+
199
+ Quaternion WristLeft;
200
+
201
+ Quaternion HandLeft;
202
+
203
+ Quaternion ElbowRight;
204
+
205
+ Quaternion WristRight;
206
+
207
+ Quaternion HandRight;
208
+
209
+ Quaternion KneeLeft;
210
+
211
+ Quaternion AnkleLeft;
212
+
213
+ Quaternion KneeRight;
214
+
215
+ Quaternion AnkleRight;
216
+
217
+
218
+
219
+ // 鏡
220
+
221
+ if ( IsMirror ) {
222
+
223
+ SpineBase = joints[JointType.SpineBase].Orientation.ToMirror().ToQuaternion( comp );
224
+
225
+ SpineMid = joints[JointType.SpineMid].Orientation.ToMirror().ToQuaternion( comp );
226
+
227
+ SpineShoulder = joints[JointType.SpineShoulder].Orientation.ToMirror().ToQuaternion( comp );
228
+
229
+ ShoulderLeft = joints[JointType.ShoulderRight].Orientation.ToMirror().ToQuaternion( comp );
230
+
231
+ ShoulderRight = joints[JointType.ShoulderLeft].Orientation.ToMirror().ToQuaternion( comp );
232
+
233
+ ElbowLeft = joints[JointType.ElbowRight].Orientation.ToMirror().ToQuaternion( comp );
234
+
235
+ WristLeft = joints[JointType.WristRight].Orientation.ToMirror().ToQuaternion( comp );
236
+
237
+ HandLeft = joints[JointType.HandRight].Orientation.ToMirror().ToQuaternion( comp );
238
+
239
+ ElbowRight = joints[JointType.ElbowLeft].Orientation.ToMirror().ToQuaternion( comp );
240
+
241
+ WristRight = joints[JointType.WristLeft].Orientation.ToMirror().ToQuaternion( comp );
242
+
243
+ HandRight = joints[JointType.HandLeft].Orientation.ToMirror().ToQuaternion( comp );
244
+
245
+ KneeLeft = joints[JointType.KneeRight].Orientation.ToMirror().ToQuaternion( comp );
246
+
247
+ AnkleLeft = joints[JointType.AnkleRight].Orientation.ToMirror().ToQuaternion( comp );
248
+
249
+ KneeRight = joints[JointType.KneeLeft].Orientation.ToMirror().ToQuaternion( comp );
250
+
251
+ AnkleRight = joints[JointType.AnkleLeft].Orientation.ToMirror().ToQuaternion( comp );
252
+
253
+ }
254
+
255
+ // そのまま
256
+
257
+ else {
258
+
259
+ SpineBase = joints[JointType.SpineBase].Orientation.ToQuaternion( comp );
260
+
261
+ SpineMid = joints[JointType.SpineMid].Orientation.ToQuaternion( comp );
262
+
263
+ SpineShoulder = joints[JointType.SpineShoulder].Orientation.ToQuaternion( comp );
264
+
265
+ ShoulderLeft = joints[JointType.ShoulderLeft].Orientation.ToQuaternion( comp );
266
+
267
+ ShoulderRight = joints[JointType.ShoulderRight].Orientation.ToQuaternion( comp );
268
+
269
+ ElbowLeft = joints[JointType.ElbowLeft].Orientation.ToQuaternion( comp );
270
+
271
+ WristLeft = joints[JointType.WristLeft].Orientation.ToQuaternion( comp );
272
+
273
+ HandLeft = joints[JointType.HandLeft].Orientation.ToQuaternion( comp );
274
+
275
+ ElbowRight = joints[JointType.ElbowRight].Orientation.ToQuaternion( comp );
276
+
277
+ WristRight = joints[JointType.WristRight].Orientation.ToQuaternion( comp );
278
+
279
+ HandRight = joints[JointType.HandRight].Orientation.ToQuaternion( comp );
280
+
281
+ KneeLeft = joints[JointType.KneeLeft].Orientation.ToQuaternion( comp );
282
+
283
+ AnkleLeft = joints[JointType.AnkleLeft].Orientation.ToQuaternion( comp );
284
+
285
+ KneeRight = joints[JointType.KneeRight].Orientation.ToQuaternion( comp );
286
+
287
+ AnkleRight = joints[JointType.AnkleRight].Orientation.ToQuaternion( comp );
288
+
289
+ }
290
+
291
+
292
+
293
+ // 関節の回転を計算する
294
+
295
+ var q = transform.rotation;
296
+
297
+ transform.rotation = Quaternion.identity;
298
+
299
+
300
+
301
+ var comp2 = Quaternion.AngleAxis( 90, new Vector3( 0, 1, 0 ) ) *
302
+
303
+ Quaternion.AngleAxis( -90, new Vector3( 0, 0, 1 ) );
304
+
305
+
306
+
307
+ Spine1.transform.rotation = SpineMid * comp2;
308
+
309
+
310
+
311
+ RightArm.transform.rotation = ElbowRight * comp2;
312
+
313
+ RightForeArm.transform.rotation = WristRight * comp2;
314
+
315
+ RightHand.transform.rotation = HandRight * comp2;
316
+
317
+
318
+
319
+ LeftArm.transform.rotation = ElbowLeft * comp2;
320
+
321
+ LeftForeArm.transform.rotation = WristLeft * comp2;
322
+
323
+ LeftHand.transform.rotation = HandLeft * comp2;
324
+
325
+
326
+
327
+ RightUpLeg.transform.rotation = KneeRight * comp2;
328
+
329
+ RightLeg.transform.rotation = AnkleRight * comp2;
330
+
331
+
332
+
333
+ LeftUpLeg.transform.rotation = KneeLeft * Quaternion.AngleAxis( -90, new Vector3( 0, 0, 1 ) );
334
+
335
+ LeftLeg.transform.rotation = AnkleLeft * Quaternion.AngleAxis( -90, new Vector3( 0, 0, 1 ) );
336
+
337
+
338
+
339
+ // モデルの回転を設定する
340
+
341
+ transform.rotation = q;
342
+
343
+
344
+
345
+ // モデルの位置を移動する
346
+
347
+ var pos = body.Joints[JointType.SpineMid].Position;
348
+
349
+ Ref.transform.position = new Vector3( -pos.X, pos.Y, -pos.Z );
350
+
351
+ }
352
+
353
+ }
354
+
355
+
356
+
357
+ ```
358
+
359
+ - Assets/KinectAvatar.cs(78,39): error CS1061: Type `BodySourceManager' does not contain a definition for `FloorClipPlane' and no extension method `FloorClipPlane' of type `BodySourceManager' could be found. Are you missing an assembly reference?
360
+
361
+
362
+
363
+ -Assets/KinectAvatar.cs(103,65): error CS1061: Type `Windows.Kinect.Vector4' does not contain a definition for `ToMirror' and no extension method `ToMirror' of type `Windows.Kinect.Vector4' could be found. Are you missing an assembly reference?
364
+
365
+
366
+
367
+ - Assets/KinectAvatar.cs(121,65): error CS1061: Type `Windows.Kinect.Vector4' does not contain a definition for `ToQuaternion' and no extension method `ToQuaternion' of type `Windows.Kinect.Vector4' could be found. Are you missing an assembly reference?
50
368
 
51
369
 
52
370
 
@@ -56,4 +374,4 @@
56
374
 
57
375
 
58
376
 
59
- windows 10 , unity2018.2.19 , kinect v2 ,
377
+ windows 10 , unity2017.1 , kinect v2 , visualstudio2017 ,

2

URLの修正

2018/12/17 07:41

投稿

shiro16
shiro16

スコア15

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- kinect for windows : [リンク](http://www.microsoft.com/en-us/kinectforwindows/default.aspx) からダウンロードしてきたものをインポートする
11
+ kinect for windows : [リンク](https://www.microsoft.com/en-us/download/details.aspx?id=44561) からダウンロードしてきたものをインポートする
12
12
 
13
13
  ことはできたのですが、スクリプトに以下のようなエラーが出て動きません。
14
14
 

1

誤字

2018/12/09 08:36

投稿

shiro16
shiro16

スコア15

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- [kinect for windows](http://www.microsoft.com/en-us/kinectforwindows/default.aspx) からダウンロードしてきたものをインポートする
11
+ kinect for windows : [リンク](http://www.microsoft.com/en-us/kinectforwindows/default.aspx) からダウンロードしてきたものをインポートする
12
12
 
13
13
  ことはできたのですが、スクリプトに以下のようなエラーが出て動きません。
14
14