質問編集履歴
2
メソッドを呼び出している箇所についての説明を記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,4 +44,32 @@
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
47
|
-
```
|
47
|
+
```
|
48
|
+
|
49
|
+
|
50
|
+
```c#
|
51
|
+
//GetPlacedPArt()を呼び出している箇所
|
52
|
+
private void SetMarker(HintMarker marker)
|
53
|
+
{
|
54
|
+
target = marker.GetPlacedPart();
|
55
|
+
isSelecting = !ReferenceEquals(target, null);
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
```c#
|
60
|
+
//SetMarker()を呼び出している箇所
|
61
|
+
if (EventSystem.current.IsPointerOverGameObject(0) || EventSystem.current.IsPointerOverGameObject()) //UIをタッチしている場合は適用しない
|
62
|
+
return;
|
63
|
+
|
64
|
+
Ray rayBegan = Camera.main.ScreenPointToRay(TouchUtility.GetTouchPosition());
|
65
|
+
RaycastHit hit;
|
66
|
+
if (!Physics.Raycast(rayBegan, out hit))
|
67
|
+
return;
|
68
|
+
|
69
|
+
var marker = hit.transform.gameObject.GetComponent<HintMarker>();
|
70
|
+
if (marker != null)
|
71
|
+
{
|
72
|
+
SetMarker(marker);
|
73
|
+
}
|
74
|
+
```
|
75
|
+
RayCastでヒントマーカーを持つオブジェクトを検知し、GetComponent()でHintMarkerを取得し、件のメソッドを呼び出しています。
|
1
スクリプトのソースコードを追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,4 +5,43 @@
|
|
5
5
|
ゲーム中にインスペクターからこの変数を確認すると確かに参照が入っています。
|
6
6
|

|
7
7
|
|
8
|
-
どなたかこういった現象の原因に心当たりがある方アドバイスいただきたいです。
|
8
|
+
どなたかこういった現象の原因に心当たりがある方アドバイスいただきたいです。
|
9
|
+
|
10
|
+
```c#
|
11
|
+
using System.Collections;
|
12
|
+
using System.Collections.Generic;
|
13
|
+
using UnityEngine;
|
14
|
+
|
15
|
+
public class HintMarker : MonoBehaviour
|
16
|
+
{
|
17
|
+
public PuzzleParts PlacedPart = null;
|
18
|
+
|
19
|
+
// Start is called before the first frame update
|
20
|
+
void Start()
|
21
|
+
{
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
// Update is called once per frame
|
26
|
+
void Update()
|
27
|
+
{
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
public PuzzleParts PickPartUp()
|
32
|
+
{
|
33
|
+
var part = PlacedPart;
|
34
|
+
PlacedPart = null;
|
35
|
+
return part;
|
36
|
+
}
|
37
|
+
|
38
|
+
public PuzzleParts GetPlacedPart()
|
39
|
+
{
|
40
|
+
if (ReferenceEquals(PlacedPart, null))
|
41
|
+
Debug.Log("何もパーツがセットされていません : " + PlacedPart, gameObject);
|
42
|
+
|
43
|
+
return PlacedPart;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
```
|