-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartScreenUI.cs
More file actions
38 lines (31 loc) · 1.19 KB
/
StartScreenUI.cs
File metadata and controls
38 lines (31 loc) · 1.19 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
using UnityEngine;
using UnityEngine.UI;
public class StartScreenUI : MonoBehaviour
{
[Header("UI")]
public GameObject startPanel; // full-screen panel
public Text messageText; // Legacy Text
[TextArea] public string message = "Can you get to 300 points?\nTap Start when you're ready.";
[Header("Other UI to toggle")]
public GameObject gameplayGroup; // parent with ScoreText + HeartsParent, etc.
public GameObject gameOverPanel; // your existing game over panel (optional)
void Awake()
{
// Show start, hide gameplay + game over
if (startPanel) startPanel.SetActive(true);
if (gameplayGroup) gameplayGroup.SetActive(false);
if (gameOverPanel) gameOverPanel.SetActive(false);
if (messageText) messageText.text = message;
// Pause everything
Time.timeScale = 0f;
}
// Hook this to StartButton.onClick
public void StartGame()
{
if (startPanel) startPanel.SetActive(false);
if (gameplayGroup) gameplayGroup.SetActive(true);
// Optional: reset score
if (ScoreManager.Instance != null) ScoreManager.Instance.ResetScore();
Time.timeScale = 1f;
}
}