質問編集履歴

3

助けて下さい

2020/04/01 17:05

投稿

kidaer
kidaer

スコア31

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  上記で入るようになりました。
42
42
 
43
- しかし別のシーンからsintを呼び出そうとして
43
+ しかし別のシーンからaaaを呼び出そうとして
44
44
 
45
45
  ========================
46
46
 
@@ -53,8 +53,6 @@
53
53
  using System;
54
54
 
55
55
  using UnityEngine.UI;
56
-
57
-
58
56
 
59
57
 
60
58
 
@@ -80,13 +78,15 @@
80
78
 
81
79
  // オブジェクトからTextコンポーネントを取得
82
80
 
81
+ int b = titleJup.aaa;
82
+
83
83
 
84
84
 
85
85
  Text score_text = score_object.GetComponent<Text> ();
86
86
 
87
87
  // テキストの表示を入れ替える
88
88
 
89
- score_text.text = aaa;
89
+ score_text.text = b;
90
90
 
91
91
  }
92
92
 
@@ -94,6 +94,24 @@
94
94
 
95
95
  =========================
96
96
 
97
- とするですが再生できずにいます
97
+ 今こ状態から進めずにいます
98
98
 
99
+ score_text.text = b;を"b"にすれば再生できるのですが、変数にすると再生できなくなります。
100
+
101
+ またエラーが出ています
102
+
103
+ =========================
104
+
105
+ Cannot implicitly convert type `int' to `String'
106
+
107
+ これともうひとつ
108
+
109
+ All compiler errors have be fixed before you can playmodo!
110
+
111
+ unityEdter.SceneVieW:ShowCompileErrorNotification()(atC:/buikdskave/unity/build/Editor/Mono/SceneView/SceneView.cs:2935)
112
+
113
+ =================================================
114
+
115
+ 上記の内容がでており、ぐぐったのですがよくわかりませんでした。
116
+
99
- どうしたらいいでしょうか?
117
+ どうしたらいいでしょうか?

2

一文抜けていたので修正しました

2020/04/01 17:05

投稿

kidaer
kidaer

スコア31

test CHANGED
File without changes
test CHANGED
@@ -19,6 +19,8 @@
19
19
  public class titleJup : MonoBehaviour {
20
20
 
21
21
 
22
+
23
+ public static int aaa;
22
24
 
23
25
  // ボタンが押された場合、今回呼び出される関数
24
26
 

1

状況が変わったので質問を更新しました

2020/04/01 16:18

投稿

kidaer
kidaer

スコア31

test CHANGED
File without changes
test CHANGED
@@ -4,28 +4,94 @@
4
4
 
5
5
  =======================
6
6
 
7
+ using System.Collections;
8
+
9
+ using System.Collections.Generic;
10
+
7
11
  using UnityEngine;
12
+
13
+ using UnityEngine.SceneManagement;
14
+
15
+ using UnityEngine.UI;
16
+
17
+
18
+
19
+ public class titleJup : MonoBehaviour {
8
20
 
9
21
 
10
22
 
11
- public class 変宣言 : MonoBehaviour {
23
+ // ボタンが押された場合、今回呼び出される関
12
24
 
13
- {
14
-
15
- public void Start () {
25
+ public void OnClick()
16
26
 
17
27
  {
18
28
 
19
- public static int score = 0;
29
+ int aaa = (Random.Range (1, 10));
30
+
31
+ Debug.Log(aaa); // ログを出力
32
+
33
+ SceneManager.LoadScene("画面2");
20
34
 
21
35
  }
22
36
 
23
- }
37
+ }===========================
38
+
39
+ 上記で入るようになりました。
40
+
41
+ しかし別のシーンからsintを呼び出そうとして
24
42
 
25
43
  ========================
26
44
 
27
- シーン間で共有する変数にはpublicをつけると見たのですが、再生すらできない状態です。
45
+ using System.Collections;
28
46
 
29
- どうしたらいいのでしょうか?
47
+ using System.Collections.Generic;
30
48
 
49
+ using UnityEngine;
50
+
51
+ using System;
52
+
53
+ using UnityEngine.UI;
54
+
55
+
56
+
57
+
58
+
59
+ public class 文字変数 : MonoBehaviour {
60
+
61
+
62
+
63
+ public GameObject score_object = null; // Textオブジェクト
64
+
65
+
66
+
67
+ // 初期化
68
+
69
+ void Start () {
70
+
71
+ }
72
+
73
+
74
+
75
+ // 更新
76
+
77
+ void Update () {
78
+
79
+ // オブジェクトからTextコンポーネントを取得
80
+
81
+
82
+
83
+ Text score_text = score_object.GetComponent<Text> ();
84
+
85
+ // テキストの表示を入れ替える
86
+
87
+ score_text.text = aaa;
88
+
89
+ }
90
+
91
+ }
92
+
93
+ =========================
94
+
95
+ とするのですが再生できずにいます
96
+
31
- よろくお願いします
97
+ どうたらいでょうか?