質問編集履歴
3
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,9 +82,7 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
-
|
85
|
+
|
86
|
-
|
87
|
-
//あるいはここで新たに定義した変数をUpdate()の関数に共有する
|
88
86
|
|
89
87
|
var fingerController = gameObject.AddComponent<FingerController>();
|
90
88
|
|
2
回答がなかったため、書き方を変えました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Unity SteamVR_Input_Actions.cs内のNullReferenceExceptionを解消する方法
|
test
CHANGED
@@ -1,18 +1,42 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
+
純文系人間ですが、仕事の一環で初めてのプログラミングをしております。
|
4
|
+
|
5
|
+
知識不足のため質問内容などわかりにくいところがあるかと思いますが、ご回答いただければ幸いです。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
3
11
|
unityでHTC VIVEのハンドコントローラーのトラックパッドを4分割して
|
4
12
|
|
5
|
-
キャラクターの指を動か
|
13
|
+
キャラクターの指を動かそうと考えています。
|
14
|
+
|
6
|
-
|
15
|
+
そこで以下のコードを作成したところ、NullReferenceExceptionが出てしまい
|
7
|
-
|
8
|
-
|
16
|
+
|
9
|
-
|
17
|
+
unityの再生では問題ないのですが、ビルドがうまくいきません。
|
10
|
-
|
18
|
+
|
19
|
+
|
20
|
+
|
11
|
-
|
21
|
+
どうして作成したコードをunityにアタッチすると該当箇所がnullになってしまうのか
|
12
|
-
|
13
|
-
|
14
|
-
|
22
|
+
|
15
|
-
|
23
|
+
そしてどのようにして対処すればよいか教えてください。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
### 発生している問題・エラーメッセージ
|
30
|
+
|
31
|
+
Do not use ReadObjectThread on scene object
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
NullReferenceException: Object reference not set to an instance of an object
|
36
|
+
|
37
|
+
Valve.VR.SteamVR_Actions.get_default_TrackPad () (at Assets/SteamVR_Input/SteamVR_Input_Actions.cs:132)
|
38
|
+
|
39
|
+
TrackpadControl..ctor () (at Assets/TrackpadControl.cs:9)
|
16
40
|
|
17
41
|
|
18
42
|
|
@@ -40,11 +64,7 @@
|
|
40
64
|
|
41
65
|
{
|
42
66
|
|
43
|
-
|
67
|
+
|
44
|
-
|
45
|
-
//(Assets/SteamVR_Input/SteamVR_Input_Actions.cs:132)が発生する。
|
46
|
-
|
47
|
-
|
48
68
|
|
49
69
|
private SteamVR_Action_Vector2 TrackPad = SteamVR_Actions.default_TrackPad;
|
50
70
|
|
@@ -56,6 +76,22 @@
|
|
56
76
|
|
57
77
|
|
58
78
|
|
79
|
+
void Start()
|
80
|
+
|
81
|
+
{
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
//ここでは上で生成したobjectにvar fingerControllerという変数を付与しUpdate()で呼び出す
|
86
|
+
|
87
|
+
//あるいはここで新たに定義した変数をUpdate()の関数に共有する
|
88
|
+
|
89
|
+
var fingerController = gameObject.AddComponent<FingerController>();
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
}
|
94
|
+
|
59
95
|
// Update is called once per frame
|
60
96
|
|
61
97
|
void Update()
|
@@ -198,17 +234,283 @@
|
|
198
234
|
|
199
235
|
```
|
200
236
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
237
|
+
エラー箇所の内容は以下(コードの一番下)
|
238
|
+
|
239
|
+
```ここに言語を入力
|
240
|
+
|
241
|
+
//------------------------------------------------------------------------------
|
242
|
+
|
243
|
+
// <auto-generated>
|
244
|
+
|
245
|
+
// This code was generated by a tool.
|
246
|
+
|
247
|
+
// Runtime Version:4.0.30319.42000
|
248
|
+
|
249
|
+
//
|
250
|
+
|
251
|
+
// Changes to this file may cause incorrect behavior and will be lost if
|
252
|
+
|
253
|
+
// the code is regenerated.
|
254
|
+
|
255
|
+
// </auto-generated>
|
256
|
+
|
257
|
+
//------------------------------------------------------------------------------
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
namespace Valve.VR
|
262
|
+
|
263
|
+
{
|
264
|
+
|
265
|
+
using System;
|
266
|
+
|
267
|
+
using UnityEngine;
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
public partial class SteamVR_Actions
|
274
|
+
|
275
|
+
{
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
private static SteamVR_Action_Boolean p_default_InteractUI;
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
private static SteamVR_Action_Boolean p_default_Teleport;
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
private static SteamVR_Action_Boolean p_default_GrabPinch;
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
private static SteamVR_Action_Boolean p_default_GrabGrip;
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
private static SteamVR_Action_Pose p_default_Pose;
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
private static SteamVR_Action_Skeleton p_default_SkeletonLeftHand;
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
private static SteamVR_Action_Skeleton p_default_SkeletonRightHand;
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
private static SteamVR_Action_Single p_default_Squeeze;
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
private static SteamVR_Action_Boolean p_default_HeadsetOnHead;
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
private static SteamVR_Action_Vector2 p_default_TrackPad;
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
private static SteamVR_Action_Vibration p_default_Haptic;
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
private static SteamVR_Action_Vector2 p_platformer_Move;
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
private static SteamVR_Action_Boolean p_platformer_Jump;
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
private static SteamVR_Action_Vector2 p_buggy_Steering;
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
private static SteamVR_Action_Single p_buggy_Throttle;
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
private static SteamVR_Action_Boolean p_buggy_Brake;
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
private static SteamVR_Action_Boolean p_buggy_Reset;
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
private static SteamVR_Action_Pose p_mixedreality_ExternalCamera;
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
public static SteamVR_Action_Boolean default_InteractUI
|
352
|
+
|
353
|
+
{
|
354
|
+
|
355
|
+
get
|
356
|
+
|
357
|
+
{
|
358
|
+
|
359
|
+
return SteamVR_Actions.p_default_InteractUI.GetCopy<SteamVR_Action_Boolean>();
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
public static SteamVR_Action_Boolean default_Teleport
|
368
|
+
|
369
|
+
{
|
370
|
+
|
371
|
+
get
|
372
|
+
|
373
|
+
{
|
374
|
+
|
375
|
+
return SteamVR_Actions.p_default_Teleport.GetCopy<SteamVR_Action_Boolean>();
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
public static SteamVR_Action_Boolean default_GrabPinch
|
384
|
+
|
385
|
+
{
|
386
|
+
|
387
|
+
get
|
388
|
+
|
389
|
+
{
|
390
|
+
|
391
|
+
return SteamVR_Actions.p_default_GrabPinch.GetCopy<SteamVR_Action_Boolean>();
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
public static SteamVR_Action_Boolean default_GrabGrip
|
400
|
+
|
401
|
+
{
|
402
|
+
|
403
|
+
get
|
404
|
+
|
405
|
+
{
|
406
|
+
|
407
|
+
return SteamVR_Actions.p_default_GrabGrip.GetCopy<SteamVR_Action_Boolean>();
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
}
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
public static SteamVR_Action_Pose default_Pose
|
416
|
+
|
417
|
+
{
|
418
|
+
|
419
|
+
get
|
420
|
+
|
421
|
+
{
|
422
|
+
|
423
|
+
return SteamVR_Actions.p_default_Pose.GetCopy<SteamVR_Action_Pose>();
|
424
|
+
|
425
|
+
}
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
public static SteamVR_Action_Skeleton default_SkeletonLeftHand
|
432
|
+
|
433
|
+
{
|
434
|
+
|
435
|
+
get
|
436
|
+
|
437
|
+
{
|
438
|
+
|
439
|
+
return SteamVR_Actions.p_default_SkeletonLeftHand.GetCopy<SteamVR_Action_Skeleton>();
|
440
|
+
|
441
|
+
}
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
public static SteamVR_Action_Skeleton default_SkeletonRightHand
|
448
|
+
|
449
|
+
{
|
450
|
+
|
451
|
+
get
|
452
|
+
|
453
|
+
{
|
454
|
+
|
455
|
+
return SteamVR_Actions.p_default_SkeletonRightHand.GetCopy<SteamVR_Action_Skeleton>();
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
public static SteamVR_Action_Single default_Squeeze
|
464
|
+
|
465
|
+
{
|
466
|
+
|
467
|
+
get
|
468
|
+
|
469
|
+
{
|
470
|
+
|
471
|
+
return SteamVR_Actions.p_default_Squeeze.GetCopy<SteamVR_Action_Single>();
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
public static SteamVR_Action_Boolean default_HeadsetOnHead
|
480
|
+
|
481
|
+
{
|
482
|
+
|
483
|
+
get
|
484
|
+
|
485
|
+
{
|
486
|
+
|
487
|
+
return SteamVR_Actions.p_default_HeadsetOnHead.GetCopy<SteamVR_Action_Boolean>();
|
488
|
+
|
489
|
+
}
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
public static SteamVR_Action_Vector2 default_TrackPad
|
496
|
+
|
497
|
+
{
|
498
|
+
|
499
|
+
get
|
500
|
+
|
501
|
+
{
|
502
|
+
|
503
|
+
//↓ここがnullになってしまう
|
504
|
+
|
505
|
+
return SteamVR_Actions.p_default_TrackPad.GetCopy<SteamVR_Action_Vector2>();
|
506
|
+
|
507
|
+
}
|
508
|
+
|
509
|
+
}
|
510
|
+
|
511
|
+
```
|
512
|
+
|
513
|
+
|
212
514
|
|
213
515
|
|
214
516
|
|
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,6 +12,10 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
数日悩んでいるのですが、解決できないためご助言をお願いいたします。
|
16
|
+
|
17
|
+
|
18
|
+
|
15
19
|
|
16
20
|
|
17
21
|
### 該当のソースコード
|