質問編集履歴
3
文追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,145 @@
|
|
25
25
|
|
26
26
|
|
27
27
|
このスコアはUnityでシーン移行後に持ってきた変数の値を一発で表示するものです。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
using System;
|
32
|
+
|
33
|
+
using UnityEngine;
|
34
|
+
|
35
|
+
using System.Collections;
|
36
|
+
|
37
|
+
using UnityEngine.UI;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
public class TimeCounter : MonoBehaviour
|
42
|
+
|
43
|
+
{
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
[SerializeField]
|
48
|
+
|
49
|
+
private Image[] images = new Image[4];
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
[SerializeField]
|
54
|
+
|
55
|
+
private Sprite[] numberSprites = new Sprite[10];
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
private float latetime = 0;
|
60
|
+
|
61
|
+
public float timeCount { get; set; }
|
62
|
+
|
63
|
+
public static float timeresult;
|
64
|
+
|
65
|
+
public static float lateresult;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
void Start()
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
SetTime(900);
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
void Update()
|
80
|
+
|
81
|
+
{
|
82
|
+
|
83
|
+
//if(Input.GetKeyDown(KeyCode.Y))
|
84
|
+
|
85
|
+
//{
|
86
|
+
|
87
|
+
// timeresult = timeCount;
|
88
|
+
|
89
|
+
// lateresult = latetime;
|
90
|
+
|
91
|
+
// FadeManager.Instance.LoadLevel("Result", 0.5f);
|
92
|
+
|
93
|
+
//}
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
public void SetTime(float time)
|
100
|
+
|
101
|
+
{
|
102
|
+
|
103
|
+
timeCount = time;
|
104
|
+
|
105
|
+
StartCoroutine(TimerStart());
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
void SetNumbers(int sec, int val1, int val2)
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
string str = String.Format("{0:00}", sec);
|
116
|
+
|
117
|
+
images[val1].sprite = numberSprites[Convert.ToInt32(str.Substring(0, 1))];
|
118
|
+
|
119
|
+
images[val2].sprite = numberSprites[Convert.ToInt32(str.Substring(1, 1))];
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
IEnumerator TimerStart()
|
126
|
+
|
127
|
+
{
|
128
|
+
|
129
|
+
while (timeCount > 0)
|
130
|
+
|
131
|
+
{
|
132
|
+
|
133
|
+
int sec = Mathf.FloorToInt(timeCount % 60);
|
134
|
+
|
135
|
+
SetNumbers(sec, 2, 3);
|
136
|
+
|
137
|
+
int minu = Mathf.FloorToInt((timeCount - sec) / 60);
|
138
|
+
|
139
|
+
SetNumbers(minu, 0, 1);
|
140
|
+
|
141
|
+
yield return new WaitForSeconds(1.0f);
|
142
|
+
|
143
|
+
timeCount -= 1.0f;
|
144
|
+
|
145
|
+
latetime += 1.0f;
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
TimeOver();
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
void TimeOver()
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
timeresult = timeCount;
|
160
|
+
|
161
|
+
lateresult = latetime;
|
162
|
+
|
163
|
+
FadeManager.Instance.LoadLevel("Result", 0.5f);
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
上記のスクリプトのなかにあるtimeresultとlateresultを引っ張り出したいです。
|
2
文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,4 +24,4 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
このスコアはUnityでシーン移行後に持ってきた値を一発で表示するものです。
|
27
|
+
このスコアはUnityでシーン移行後に持ってきた変数の値を一発で表示するものです。
|
1
文の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,7 @@
|
|
21
21
|
上に表示しているものを使います。
|
22
22
|
|
23
23
|
この画像は個々に分かれている数字です。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
このスコアはUnityでシーン移行後に持ってきた値を一発で表示するものです。
|