teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

誤字修正

2019/09/30 04:19

投稿

ra7ra7_430
ra7ra7_430

スコア5

title CHANGED
File without changes
body CHANGED
@@ -40,8 +40,7 @@
40
40
  void Start()
41
41
  {
42
42
 
43
- //ここでは上で生成したobjectにvar fingerControllerという変数を付与しUpdate()で呼び出す
43
+
44
- //あるいはここで新たに定義した変数をUpdate()の関数に共有する
45
44
  var fingerController = gameObject.AddComponent<FingerController>();
46
45
 
47
46
  }

2

回答がなかったため、書き方を変えました。

2019/09/30 04:19

投稿

ra7ra7_430
ra7ra7_430

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- HTC VIVEハンドコントローラーのトラックパッド使ってキャラクターの指を動かしたい。
1
+ Unity SteamVR_Input_Actions.cs内NullReferenceException解消する方法
body CHANGED
@@ -1,13 +1,25 @@
1
1
  ### 前提・実現したいこと
2
+ 純文系人間ですが、仕事の一環で初めてのプログラミングをしております。
3
+ 知識不足のため質問内容などわかりにくいところがあるかと思いますが、ご回答いただければ幸いです。
4
+
5
+
2
6
  unityでHTC VIVEのハンドコントローラーのトラックパッドを4分割して
3
- キャラクターの指を動かしたす。
7
+ キャラクターの指を動かそうと考えてす。
8
+ そこで以下のコードを作成したところ、NullReferenceExceptionが出てしまい
9
+ unityの再生では問題ないのですが、ビルドがうまくいきません。
4
10
 
5
- Unityのビューでは問題なく動いのですが、ビルドするとントロラーのボべて
11
+ どうして作成したコードをunityにアッチると該当箇所nullになってしまうのか
6
- 反応ない状態なります。
12
+ てどのようして対処ればよいか教えてください
7
13
 
8
- 数日悩んでいるのですが、解決できないためご助言をお願いいたします。
9
14
 
15
+ ### 発生している問題・エラーメッセージ
16
+ Do not use ReadObjectThread on scene object
10
17
 
18
+ NullReferenceException: Object reference not set to an instance of an object
19
+ Valve.VR.SteamVR_Actions.get_default_TrackPad () (at Assets/SteamVR_Input/SteamVR_Input_Actions.cs:132)
20
+ TrackpadControl..ctor () (at Assets/TrackpadControl.cs:9)
21
+
22
+
11
23
  ### 該当のソースコード
12
24
  以下のコードを作成しました。
13
25
  ```ここに言語を入力
@@ -19,14 +31,20 @@
19
31
 
20
32
  public class TrackpadControl : MonoBehaviour
21
33
  {
22
-   //↓これのせいか、 NullReferenceException
34
+
23
- //(Assets/SteamVR_Input/SteamVR_Input_Actions.cs:132)が発生する。
24
-
25
35
  private SteamVR_Action_Vector2 TrackPad = SteamVR_Actions.default_TrackPad;
26
36
 
27
37
  private Vector2 pos, pos2;
28
38
  }
29
39
 
40
+ void Start()
41
+ {
42
+
43
+ //ここでは上で生成したobjectにvar fingerControllerという変数を付与しUpdate()で呼び出す
44
+ //あるいはここで新たに定義した変数をUpdate()の関数に共有する
45
+ var fingerController = gameObject.AddComponent<FingerController>();
46
+
47
+ }
30
48
  // Update is called once per frame
31
49
  void Update()
32
50
  {
@@ -98,13 +116,146 @@
98
116
  }
99
117
  }
100
118
  ```
119
+ エラー箇所の内容は以下(コードの一番下)
120
+ ```ここに言語を入力
121
+ //------------------------------------------------------------------------------
122
+ // <auto-generated>
123
+ // This code was generated by a tool.
124
+ // Runtime Version:4.0.30319.42000
125
+ //
126
+ // Changes to this file may cause incorrect behavior and will be lost if
127
+ // the code is regenerated.
128
+ // </auto-generated>
129
+ //------------------------------------------------------------------------------
101
130
 
102
- ### 発生している問題・エラーメッセージ
131
+ namespace Valve.VR
132
+ {
133
+ using System;
103
- Do not use ReadObjectThread on scene object
134
+ using UnityEngine;
104
- NullReferenceException: Object reference not set to an instance of an object
105
- Valve.VR.SteamVR_Actions.get_default_TrackPad () (at Assets/SteamVR_Input/SteamVR_Input_Actions.cs:132)
106
- TrackpadControl..ctor () (at Assets/TrackpadControl.cs:9)
107
135
 
136
+
137
+ public partial class SteamVR_Actions
138
+ {
139
+
140
+ private static SteamVR_Action_Boolean p_default_InteractUI;
141
+
142
+ private static SteamVR_Action_Boolean p_default_Teleport;
143
+
144
+ private static SteamVR_Action_Boolean p_default_GrabPinch;
145
+
146
+ private static SteamVR_Action_Boolean p_default_GrabGrip;
147
+
148
+ private static SteamVR_Action_Pose p_default_Pose;
149
+
150
+ private static SteamVR_Action_Skeleton p_default_SkeletonLeftHand;
151
+
152
+ private static SteamVR_Action_Skeleton p_default_SkeletonRightHand;
153
+
154
+ private static SteamVR_Action_Single p_default_Squeeze;
155
+
156
+ private static SteamVR_Action_Boolean p_default_HeadsetOnHead;
157
+
158
+ private static SteamVR_Action_Vector2 p_default_TrackPad;
159
+
160
+ private static SteamVR_Action_Vibration p_default_Haptic;
161
+
162
+ private static SteamVR_Action_Vector2 p_platformer_Move;
163
+
164
+ private static SteamVR_Action_Boolean p_platformer_Jump;
165
+
166
+ private static SteamVR_Action_Vector2 p_buggy_Steering;
167
+
168
+ private static SteamVR_Action_Single p_buggy_Throttle;
169
+
170
+ private static SteamVR_Action_Boolean p_buggy_Brake;
171
+
172
+ private static SteamVR_Action_Boolean p_buggy_Reset;
173
+
174
+ private static SteamVR_Action_Pose p_mixedreality_ExternalCamera;
175
+
176
+ public static SteamVR_Action_Boolean default_InteractUI
177
+ {
178
+ get
179
+ {
180
+ return SteamVR_Actions.p_default_InteractUI.GetCopy<SteamVR_Action_Boolean>();
181
+ }
182
+ }
183
+
184
+ public static SteamVR_Action_Boolean default_Teleport
185
+ {
186
+ get
187
+ {
188
+ return SteamVR_Actions.p_default_Teleport.GetCopy<SteamVR_Action_Boolean>();
189
+ }
190
+ }
191
+
192
+ public static SteamVR_Action_Boolean default_GrabPinch
193
+ {
194
+ get
195
+ {
196
+ return SteamVR_Actions.p_default_GrabPinch.GetCopy<SteamVR_Action_Boolean>();
197
+ }
198
+ }
199
+
200
+ public static SteamVR_Action_Boolean default_GrabGrip
201
+ {
202
+ get
203
+ {
204
+ return SteamVR_Actions.p_default_GrabGrip.GetCopy<SteamVR_Action_Boolean>();
205
+ }
206
+ }
207
+
208
+ public static SteamVR_Action_Pose default_Pose
209
+ {
210
+ get
211
+ {
212
+ return SteamVR_Actions.p_default_Pose.GetCopy<SteamVR_Action_Pose>();
213
+ }
214
+ }
215
+
216
+ public static SteamVR_Action_Skeleton default_SkeletonLeftHand
217
+ {
218
+ get
219
+ {
220
+ return SteamVR_Actions.p_default_SkeletonLeftHand.GetCopy<SteamVR_Action_Skeleton>();
221
+ }
222
+ }
223
+
224
+ public static SteamVR_Action_Skeleton default_SkeletonRightHand
225
+ {
226
+ get
227
+ {
228
+ return SteamVR_Actions.p_default_SkeletonRightHand.GetCopy<SteamVR_Action_Skeleton>();
229
+ }
230
+ }
231
+
232
+ public static SteamVR_Action_Single default_Squeeze
233
+ {
234
+ get
235
+ {
236
+ return SteamVR_Actions.p_default_Squeeze.GetCopy<SteamVR_Action_Single>();
237
+ }
238
+ }
239
+
240
+ public static SteamVR_Action_Boolean default_HeadsetOnHead
241
+ {
242
+ get
243
+ {
244
+ return SteamVR_Actions.p_default_HeadsetOnHead.GetCopy<SteamVR_Action_Boolean>();
245
+ }
246
+ }
247
+
248
+ public static SteamVR_Action_Vector2 default_TrackPad
249
+ {
250
+ get
251
+ {
252
+          //↓ここがnullになってしまう
253
+ return SteamVR_Actions.p_default_TrackPad.GetCopy<SteamVR_Action_Vector2>();
254
+ }
255
+ }
256
+ ```
257
+
258
+
108
259
  ### 試したこと
109
260
 
110
261
  SteamVR_input_Actions.cs 内のエラーは(return SteamVR_Actions.p_default_TrackPad.GetCopy<SteamVR_Action_Vector2>();)で

1

文法の修正

2019/09/30 04:15

投稿

ra7ra7_430
ra7ra7_430

スコア5

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,9 @@
5
5
  Unityのビューでは問題なく動いたのですが、ビルドするとコントローラーのボタンすべてが
6
6
  反応しない状態になります。
7
7
 
8
+ 数日悩んでいるのですが、解決できないためご助言をお願いいたします。
8
9
 
10
+
9
11
  ### 該当のソースコード
10
12
  以下のコードを作成しました。
11
13
  ```ここに言語を入力