pausing with muting

This commit is contained in:
ntr committed 2023-10-10 17:13:58 +11:00
1 parent 6d5fc8a090
commit 1d078569e9
2 files changed
+14

No files matched your search

+12
View File
@@ -49,6 +49,18 @@ public class ShipAudio : MonoBehaviour {
SpaceRaceInput input;
ShipControls ship;
public void MuteShip() {
srcShipDecel.Stop();
srcShipAccel.Stop();
srcShipStrafe.Stop();
}
public void UnmuteShip() {
srcShipDecel.Play();
srcShipAccel.Play();
srcShipStrafe.Play();
}
void Awake() {
for (int i = 0; i < powerUnitClips.Length; i++) {
sounds.Add(powerUnitSounds[i], powerUnitClips[i]);
+2
View File
@@ -87,6 +87,7 @@ public class MenuControls : MonoBehaviour {
void Show() {
// pause the game
Time.timeScale = 0f;
shipAudio.MuteShip();
visible = true;
UnityEngine.Cursor.lockState = CursorLockMode.None;
@@ -110,6 +111,7 @@ public class MenuControls : MonoBehaviour {
void Hide() {
// unpause the game
Time.timeScale = 1f;
shipAudio.UnmuteShip();
visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.Locked;