-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeforeCountdown.cs
More file actions
54 lines (47 loc) · 1.38 KB
/
BeforeCountdown.cs
File metadata and controls
54 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class BeforeCountdown : MonoBehaviour
{
public Text countdownText; // UI Text コンポーネントをアタッチするための変数
public int countdownTime = 3; // カウントダウン時間(秒)
public static class GlobalVariables
{
public static bool startFlag = False;
}
private void Start()
{
}
void Update()
{
if (startFlag == True)
{
StartCoroutine(StartCountdown());
}
}
private IEnumerator StartCountdown()
{
// カウントダウンのループ
while (countdownTime > 0)
{
// 現在のカウントを表示
countdownText.text = countdownTime.ToString();
// 1秒待つ
yield return new WaitForSeconds(1f);
// カウントを減らす
countdownTime--;
}
// カウントダウン終了後の処理
countdownText.text = "Start!";
// 1秒待ってからテキストを非表示にする
yield return new WaitForSeconds(1f);
countdownText.gameObject.SetActive(false);
startFlag = True;
}
private void StartGame()
{
// ゲーム開始時の処理
Debug.Log("Game Started!");
// ゲーム開始の処理をここに追加
}
}