pausing with muting
This commit is contained in:
1 parent
6d5fc8a090
commit
1d078569e9
2 files changed
+14
No files matched your search
@@ -49,6 +49,18 @@ public class ShipAudio : MonoBehaviour {
|
|||||||
SpaceRaceInput input;
|
SpaceRaceInput input;
|
||||||
ShipControls ship;
|
ShipControls ship;
|
||||||
|
|
||||||
|
public void MuteShip() {
|
||||||
|
srcShipDecel.Stop();
|
||||||
|
srcShipAccel.Stop();
|
||||||
|
srcShipStrafe.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnmuteShip() {
|
||||||
|
srcShipDecel.Play();
|
||||||
|
srcShipAccel.Play();
|
||||||
|
srcShipStrafe.Play();
|
||||||
|
}
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
for (int i = 0; i < powerUnitClips.Length; i++) {
|
for (int i = 0; i < powerUnitClips.Length; i++) {
|
||||||
sounds.Add(powerUnitSounds[i], powerUnitClips[i]);
|
sounds.Add(powerUnitSounds[i], powerUnitClips[i]);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class MenuControls : MonoBehaviour {
|
|||||||
void Show() {
|
void Show() {
|
||||||
// pause the game
|
// pause the game
|
||||||
Time.timeScale = 0f;
|
Time.timeScale = 0f;
|
||||||
|
shipAudio.MuteShip();
|
||||||
|
|
||||||
visible = true;
|
visible = true;
|
||||||
UnityEngine.Cursor.lockState = CursorLockMode.None;
|
UnityEngine.Cursor.lockState = CursorLockMode.None;
|
||||||
@@ -110,6 +111,7 @@ public class MenuControls : MonoBehaviour {
|
|||||||
void Hide() {
|
void Hide() {
|
||||||
// unpause the game
|
// unpause the game
|
||||||
Time.timeScale = 1f;
|
Time.timeScale = 1f;
|
||||||
|
shipAudio.UnmuteShip();
|
||||||
|
|
||||||
visible = false;
|
visible = false;
|
||||||
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
|
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
|
||||||
|
|||||||
Reference in new issue
Block a user