Пример #1
0
 public void PauseGame(bool pause, bool showCanvas = true, bool pauseAudio = true)
 {
     if (disablePausing == false)
     {
         isPaused = pause;
         if (!isPaused) //Unpause
         {
             ToggleFreezeGameObjects(false, pauseAudio);
             if (gameMode != "menu")
             {
                 replayController.SetRecordState(true);
             }
             if (showCanvas)
             {
                 Cursor.visible   = false;
                 Cursor.lockState = CursorLockMode.Locked;
                 ToggleCurrentGameModeCamera();
                 if (gameObjectsToEnableOnPause != null)
                 {
                     foreach (GameObject go in gameObjectsToEnableOnPause)
                     {
                         if (go)
                         {
                             go.SetActive(false);
                         }
                     }
                 }
                 if (gameObjectsToEnableOnUnpause != null)
                 {
                     foreach (GameObject go in gameObjectsToEnableOnUnpause)
                     {
                         if (go)
                         {
                             go.SetActive(true);
                         }
                     }
                 }
             }
             gameTimer.SetClockState(true);
         }
         else //Pause
         {
             ToggleFreezeGameObjects(true, pauseAudio);
             replayController.SetRecordState(false);
             if (showCanvas)
             {
                 Cursor.visible   = true;
                 Cursor.lockState = CursorLockMode.Confined;
                 ToggleCamera("Demo Camera");
                 if (gameObjectsToEnableOnPause != null)
                 {
                     foreach (GameObject go in gameObjectsToEnableOnPause)
                     {
                         if (go)
                         {
                             go.SetActive(true);
                         }
                     }
                 }
                 if (gameObjectsToEnableOnUnpause != null)
                 {
                     foreach (GameObject go in gameObjectsToEnableOnUnpause)
                     {
                         if (go)
                         {
                             go.SetActive(false);
                         }
                     }
                 }
             }
             gameTimer.SetClockState(false);
         }
     }
 }