質問編集履歴
1
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
jsファイル上の処理から、C#
|
9
|
+
jsファイル上の処理から、C#ファイルに書かれたフィールドにアクセスする方法を教えてください。
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
if(col.gameObject.name == gameObject.name ){
|
42
42
|
|
43
|
-
Destroy(gameObject);
|
43
|
+
Destroy(gameObject);
|
44
44
|
|
45
45
|
|
46
46
|
|
@@ -58,4 +58,66 @@
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
+
C#ファイル
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
using UnityEngine;
|
66
|
+
|
67
|
+
using System.Collections;
|
68
|
+
|
69
|
+
using UnityEngine.UI; //ここが重要です!UIを使うときは忘れずに!
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
public class ScoreText :MonoBehaviour
|
74
|
+
|
75
|
+
{
|
76
|
+
|
77
|
+
public Text Score ; //public にしてインスペクターからTextを指定する
|
78
|
+
|
79
|
+
public static int score = 0; //score変数に得点の値が入る
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
void Start()
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
void Update()
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
Score.text = "得点 :" + score;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
public static void setScore(int scr){
|
98
|
+
|
99
|
+
score = scr;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
public static int getScore(){
|
106
|
+
|
107
|
+
return score;
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
C#ファイルで書かれたスコア記録用処理に
|
118
|
+
|
119
|
+
衝突判定処理が書かれたjsファイルからアクセスして、値を変更したいのです。
|
120
|
+
|
121
|
+
|
122
|
+
|
61
123
|
よろしくお願いいたします。
|