Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assets/Audio.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Audio/button_click_sound.wav
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Audio/button_click_sound.wav.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Assets/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ MonoBehaviour:
highScoreText: {fileID: 1516356445}
highScoreTextLegacy: {fileID: 0}
highScorePrefix: 'Best Time: '
clickSound: {fileID: 8300000, guid: d81d3106732af764fa7ffb8fb79c9b32, type: 3}
--- !u!4 &894188159
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1477,6 +1478,7 @@ MonoBehaviour:
highScoreText: {fileID: 0}
highScoreTextLegacy: {fileID: 0}
highScorePrefix: 'Best Time: '
clickSound: {fileID: 8300000, guid: d81d3106732af764fa7ffb8fb79c9b32, type: 3}
--- !u!114 &944479920
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1658,6 +1660,7 @@ GameObject:
- component: {fileID: 1088860679}
- component: {fileID: 1088860678}
- component: {fileID: 1088860677}
- component: {fileID: 1088860681}
m_Layer: 5
m_Name: Button_Capsule
m_TagString: Untagged
Expand Down Expand Up @@ -1801,6 +1804,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1088860675}
m_CullTransparentMesh: 1
--- !u!114 &1088860681
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1088860675}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 295b4262c917e204fac964af50e1a2dc, type: 3}
m_Name:
m_EditorClassIdentifier:
clickSound: {fileID: 8300000, guid: d81d3106732af764fa7ffb8fb79c9b32, type: 3}
--- !u!1 &1121022249
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2188,6 +2204,7 @@ GameObject:
- component: {fileID: 1270036536}
- component: {fileID: 1270036535}
- component: {fileID: 1270036534}
- component: {fileID: 1270036538}
m_Layer: 5
m_Name: Button_Cube
m_TagString: Untagged
Expand Down Expand Up @@ -2331,6 +2348,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1270036532}
m_CullTransparentMesh: 1
--- !u!114 &1270036538
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1270036532}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 295b4262c917e204fac964af50e1a2dc, type: 3}
m_Name:
m_EditorClassIdentifier:
clickSound: {fileID: 8300000, guid: d81d3106732af764fa7ffb8fb79c9b32, type: 3}
--- !u!1 &1423960804
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -2344,6 +2374,7 @@ GameObject:
- component: {fileID: 1423960808}
- component: {fileID: 1423960807}
- component: {fileID: 1423960806}
- component: {fileID: 1423960810}
m_Layer: 5
m_Name: Button_Sphere
m_TagString: Untagged
Expand Down Expand Up @@ -2487,6 +2518,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423960804}
m_CullTransparentMesh: 1
--- !u!114 &1423960810
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423960804}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 295b4262c917e204fac964af50e1a2dc, type: 3}
m_Name:
m_EditorClassIdentifier:
clickSound: {fileID: 8300000, guid: d81d3106732af764fa7ffb8fb79c9b32, type: 3}
--- !u!1 &1477543113
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3065,6 +3109,7 @@ GameObject:
- component: {fileID: 1655126094}
- component: {fileID: 1655126093}
- component: {fileID: 1655126092}
- component: {fileID: 1655126095}
m_Layer: 5
m_Name: Instruction
m_TagString: Untagged
Expand Down Expand Up @@ -3233,6 +3278,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1655126090}
m_CullTransparentMesh: 1
--- !u!114 &1655126095
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1655126090}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 295b4262c917e204fac964af50e1a2dc, type: 3}
m_Name:
m_EditorClassIdentifier:
clickSound: {fileID: 0}
--- !u!1 &1668237878
GameObject:
m_ObjectHideFlags: 0
Expand Down
21 changes: 21 additions & 0 deletions Assets/Scripts/ButtonClickSound.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEngine.UI;

public class ButtonClickSound : MonoBehaviour
{
public AudioClip clickSound;

void Start()
{
Button btn = GetComponent<Button>();
if (btn != null)
{
btn.onClick.AddListener(PlayClickSound);
}
}

void PlayClickSound()
{
AudioSource.PlayClipAtPoint(clickSound, Camera.main.transform.position);
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/ButtonClickSound.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions Assets/Scripts/MainMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using System.Collections;

public class MainMenu : MonoBehaviour
{
Expand All @@ -20,22 +21,19 @@ public class MainMenu : MonoBehaviour
[Tooltip("Prefix text for high score display (e.g., 'Best Time: ').")]
public string highScorePrefix = "Best Time: ";

[Header("Button Click Sound")]
public AudioClip clickSound;

private void Start()
{
// Ensure ProgressManager exists and loads progress
if (ProgressManager.Instance == null)
{
GameObject progressManagerObj = new GameObject("ProgressManager");
progressManagerObj.AddComponent<ProgressManager>();
}

// Display high score
UpdateHighScoreDisplay();
}

/// <summary>
/// Updates the high score display with the saved high score
/// </summary>
private void UpdateHighScoreDisplay()
{
if (ProgressManager.Instance == null)
Expand All @@ -55,44 +53,61 @@ private void UpdateHighScoreDisplay()
displayText += "N/A";
}

// Update TextMeshProUGUI if assigned
if (highScoreText != null)
{
highScoreText.text = displayText;
}

// Update legacy Text component if assigned
if (highScoreTextLegacy != null)
{
highScoreTextLegacy.text = displayText;
}
}
IEnumerator DelayedLoad(string sceneName)
{
if (clickSound != null)
{
AudioSource.PlayClipAtPoint(clickSound, Camera.main.transform.position, 1f);
}

yield return new WaitForSeconds(0.15f);

// Called by the Play button on the main menu. By default it will open the Level Select scene.
SceneManager.LoadScene(sceneName);
}
public void PlayGame()
{
if (!string.IsNullOrEmpty(levelSelectSceneName))
{
SceneManager.LoadScene(levelSelectSceneName);
StartCoroutine(DelayedLoad(levelSelectSceneName));
}
else
{
SceneManager.LoadScene(levelSelectBuildIndex);
StartCoroutine(DelayedLoad(SceneManager.GetSceneByBuildIndex(levelSelectBuildIndex).name));
}
}

public void QuitGame()
{
if (clickSound != null)
AudioSource.PlayClipAtPoint(clickSound, Camera.main.transform.position);

StartCoroutine(QuitDelayed());
}

IEnumerator QuitDelayed()
{
yield return new WaitForSeconds(0.15f);

#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
Debug.Log("Quit game (Editor)");
UnityEditor.EditorApplication.isPlaying = false;
#else
Debug.Log("Quit game (Build)");
Application.Quit();
#endif
}
public void GoToShop()
{
// This command loads the scene we created and named "Shop"
SceneManager.LoadScene("Shop");
StartCoroutine(DelayedLoad("Shop"));
Debug.Log("Loading Shop Scene...");
}
}
Loading