質問編集履歴
2
タイトル編集
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
unity)
|
1
|
+
unity)3D的あてゲーム Prefabで作った的に当たった時スコアを更新する
|
body
CHANGED
File without changes
|
1
ジェネレーターのスクリプト追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
3Dで作った的あてゲームにおいてPrefabを使って的を作成したのですがテキストがうまく接続できずスコアが加算されません
|
1
|
+
unity初心者です。3Dで作った的あてゲームにおいてPrefabを使って的を作成したのですがテキストがうまく接続できずスコアが加算されません
|
2
|
+
Prefabにする前はスコアは加算されていました
|
2
3
|
|
3
4
|
|
4
5
|
### 発生している問題・エラーメッセージ
|
@@ -34,14 +35,55 @@
|
|
34
35
|
{
|
35
36
|
score = 0;
|
36
37
|
}
|
38
|
+
/////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
+
using System.Collections;
|
40
|
+
using System.Collections.Generic;
|
41
|
+
using UnityEngine;
|
42
|
+
using UnityEngine.UI;
|
37
43
|
|
44
|
+
|
45
|
+
public class matoGen : MonoBehaviour
|
46
|
+
{
|
47
|
+
public GameObject mato;
|
48
|
+
int count = 0;
|
49
|
+
int max = 99;
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
// Start is called before the first frame update
|
55
|
+
void Start()
|
56
|
+
{
|
57
|
+
|
58
|
+
InvokeRepeating("Generate", 1, 6);
|
59
|
+
|
60
|
+
}
|
61
|
+
|
62
|
+
// Update is called once per frame
|
63
|
+
void Update()
|
64
|
+
{
|
65
|
+
|
66
|
+
}
|
67
|
+
void Generate()
|
68
|
+
{
|
69
|
+
if (count == max) return;
|
70
|
+
float x = Random.Range(-2.5f, 2.5f);
|
71
|
+
float y = Random.Range(6f,9f);
|
72
|
+
float z = 7;
|
73
|
+
Vector3 position = new Vector3(x, y, z);
|
74
|
+
Instantiate(mato, new Vector3(x,y,z), Quaternion.Euler(90,0,0));
|
75
|
+
count++;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
上が的本体のスクリプトで下がジェネレーターのスクリプトです
|
80
|
+
|
38
81
|
```ここに言語名を入力
|
39
82
|
ソースコード
|
40
83
|
C#
|
41
84
|
|
42
85
|
### 試したこと
|
43
86
|
|
44
|
-
CanvasのscoreテキストをPrefab化した後に的にアyとれっと接続してみた結果、接続はできたのですがスコアは何も変わりませんでした
|
45
87
|
|
46
88
|
### 補足情報(FW/ツールのバージョンなど)
|
47
89
|
|