質問編集履歴
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,105 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
```
|
19
|
+
```C#
|
20
20
|
|
21
|
+
|
22
|
+
|
23
|
+
using System.Collections;
|
24
|
+
|
25
|
+
using System.Collections.Generic;
|
26
|
+
|
27
|
+
using UnityEngine;
|
28
|
+
|
29
|
+
using UnityEngine.UI;
|
30
|
+
|
31
|
+
using UnityEngine.SceneManagement;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
public class Timecount : MonoBehaviour {
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
private int minute;
|
40
|
+
|
41
|
+
private float seconds;
|
42
|
+
|
43
|
+
//前のUpdate時の秒数
|
44
|
+
|
45
|
+
private float oldSeconds;
|
46
|
+
|
47
|
+
//タイマー表示テキスト
|
48
|
+
|
49
|
+
private Text timerText;
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
// Use this for initialization
|
54
|
+
|
55
|
+
void Start () {
|
56
|
+
|
57
|
+
minute = 1;
|
58
|
+
|
59
|
+
seconds = 0;
|
60
|
+
|
61
|
+
oldSeconds = 0;
|
62
|
+
|
63
|
+
timerText = this.GetComponent<Text>();//Textコンポーネントを取得
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
// Update is called once per frame
|
72
|
+
|
73
|
+
void Update () {
|
74
|
+
|
75
|
+
seconds -= Time.deltaTime;
|
76
|
+
|
77
|
+
if (seconds <= 0f)
|
78
|
+
|
79
|
+
{
|
80
|
+
|
21
|
-
|
81
|
+
minute--;
|
82
|
+
|
83
|
+
seconds = seconds +60;
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
//値が変わった時のみテキストUIを更新
|
90
|
+
|
91
|
+
if ((int)seconds != (int)oldSeconds)
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
timerText.text=minute.ToString("00")+":"+((int)seconds).ToString("00");
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
oldSeconds = seconds;
|
100
|
+
|
101
|
+
if (minute == 0 && seconds >= 0)
|
102
|
+
|
103
|
+
{
|
104
|
+
|
105
|
+
SceneManager.LoadScene("Result");
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
22
118
|
|
23
119
|
```
|
24
120
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|