Unity PAUSE MENU 2022 Tutorial | Beginner Friendly

Поделиться
HTML-код
  • Опубликовано: 23 дек 2024

Комментарии • 130

  • @PsychoStudiosOfficial
    @PsychoStudiosOfficial 2 года назад +12

    Does this work with locked mouse as well?

    • @garrettdeveloper
      @garrettdeveloper  2 года назад +11

      Oh yeah, I must've forgotten to add that but it's simple to do! In the script, on void Stop and void Play, you can just add Cursor.visible below the rest accordingly. So in void Stop() below Paused = true; you can add:
      Cursor.visible = true;
      And in void Play() below Paused = false; you can add
      Cursor.visible = false;
      Hope this helps too!

    • @lukasz.akozlowski2832
      @lukasz.akozlowski2832 Год назад

      @@garrettdeveloper I had the same problem but I get error CS0103 do you know what might be the problem

    • @PsychoStudiosOfficial
      @PsychoStudiosOfficial Год назад +1

      @@garrettdeveloper bro I litterly switched to ue5 because I couldn’t figure this out 💀💀

    • @garrettdeveloper
      @garrettdeveloper  Год назад +2

      @Middle school Developers ue5 is great! I've messed around with it but am too used to Unity. Hope it works out better for you ;)

    • @PsychoStudiosOfficial
      @PsychoStudiosOfficial Год назад +1

      @@garrettdeveloper it does, Thankyou!

  • @thompsonmedia8468
    @thompsonmedia8468 Год назад +5

    this was amazing thanks man got given the task of making a pause menu for my group project and this was so easy to follow

  • @Tigergamer9922
    @Tigergamer9922 Год назад +4

    Its Working Thank You

  • @Profizocker6458
    @Profizocker6458 10 месяцев назад +8

    (for me) working code of the script:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class PauseMenu : MonoBehaviour
    {
    public static bool paused = false;
    public GameObject PauseMenuCanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    }
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.Escape))
    {
    if (paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }
    }
    void Stop()
    {
    PauseMenuCanvas.SetActive(true);
    Time.timeScale = 0f;
    paused = true;
    }
    void Play()
    {
    PauseMenuCanvas.SetActive(false);
    Time.timeScale = 1f;
    paused = false;
    }
    void MainMenuButton()
    {
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
    }

    • @Profizocker6458
      @Profizocker6458 10 месяцев назад +3

      if ur mouse is locked or something and the press of the buttons doenst do anything try this:
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class PauseMenu : MonoBehaviour
      {
      public static bool paused = false;
      public GameObject PauseMenuCanvas;
      // Start is called before the first frame update
      void Start()
      {
      Time.timeScale = 1f;
      }
      // Update is called once per frame
      void Update()
      {
      if (Input.GetKeyDown(KeyCode.Escape))
      {
      if (paused)
      {
      Play();
      }
      else
      {
      Stop();
      }
      }
      }
      void Stop()
      {
      PauseMenuCanvas.SetActive(true);
      Time.timeScale = 0f;
      paused = true;
      Cursor.lockState = CursorLockMode.None;
      }
      public void Play()
      {
      PauseMenuCanvas.SetActive(false);
      Time.timeScale = 1f;
      paused = false;
      Cursor.lockState = CursorLockMode.Locked;
      }
      void MainMenuButton()
      {
      SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
      }
      }

    • @anneeve620
      @anneeve620 10 месяцев назад

      everything works except that the game isnt frozen

    • @Tarqx
      @Tarqx 8 месяцев назад

      wheres the mainmenu in the on click? i cant find it

    • @Profizocker6458
      @Profizocker6458 8 месяцев назад +1

      @@Tarqx i cant find it either and i wasnt able to do that my self i just copied it

    • @ikerpaezrodriguez9735
      @ikerpaezrodriguez9735 3 месяца назад

      use this using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class PauseMenu : MonoBehaviour
      {
      public static bool paused = false;
      public GameObject PauseMenuCanvas;
      // Start is called before the first frame update
      void Start()
      {
      Time.timeScale = 1f;
      }
      // Update is called once per frame
      void Update()
      {
      if (Input.GetKeyDown(KeyCode.Escape))
      {
      if (paused)
      {
      Play();
      }
      else
      {
      Stop();
      }
      }
      }
      public void Stop()
      {
      PauseMenuCanvas.SetActive(true);
      Time.timeScale = 0f;
      paused = true;
      Cursor.lockState = CursorLockMode.None;
      }
      public void Play()
      {
      PauseMenuCanvas.SetActive(false);
      Time.timeScale = 1f;
      paused = false;
      Cursor.lockState = CursorLockMode.Locked;
      }
      public void MainMenuButton()
      {
      SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
      }
      }

  • @CiccioPalleCazzoCulo
    @CiccioPalleCazzoCulo 2 года назад +3

    Awesome tutorial, thank you! :D

  • @pandagang1126
    @pandagang1126 Год назад +3

    hello i need some help
    i have it to where my camera moves while paused and cursor is locked.
    how do i fix this?

  • @Sy.783
    @Sy.783 2 года назад +3

    my basement children are going to love this!

  • @anastasiav4031
    @anastasiav4031 7 месяцев назад +1

    most goated tut thank u :p

  • @peterfarago7727
    @peterfarago7727 11 месяцев назад +3

    I had 2 problems. 1. I didnt get the cursor working right in the pause menu 2. I could move with my charachter while pause menu. I got solutiones both of them. First one is simple addition in the code but the second one you have to use your own playermovement script name in the code instead of my "FPSController". This code is working for me:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class PauseMenu : MonoBehaviour
    {
    public static bool paused = false;
    public GameObject PauseMenuCanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.Escape))
    {
    if (paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }
    }
    void Stop()
    {
    if (!paused)
    {
    PauseMenuCanvas.SetActive(true);
    Time.timeScale = 0f;
    paused = true;
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;

    FPSController fpsController = FindObjectOfType();
    if (fpsController != null)
    {
    fpsController.canMove = false;
    }
    }
    }
    public void Play()
    {
    if (paused)
    {
    PauseMenuCanvas.SetActive(false);
    Time.timeScale = 1f;
    paused = false;
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;

    FPSController fpsController = FindObjectOfType();
    if (fpsController != null)
    {
    fpsController.canMove = true;
    }
    }
    }
    public void MainMenuButton()
    {
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
    }

    • @Guts-King1
      @Guts-King1 9 месяцев назад

      Could you tell me why it tells me FPSController.canMove is inaccessible due to its level of protection ?

  • @Best_anim17
    @Best_anim17 10 месяцев назад +1

    what i need to do if i have 2 canvas?

  • @damiangrobler9135
    @damiangrobler9135 2 года назад +1

    For some reason when I click the buttons the mouse curser disappears... but the escape button works and pauses time correctly... hmmmm

  • @TM-TM.
    @TM-TM. 6 месяцев назад +1

    Nice tutorial everything works fine but when i click options and then click back it dosent let me open the pause menu again.
    Can you help me?

    • @garrettdeveloper
      @garrettdeveloper  6 месяцев назад

      Hi, go back and make sure you followed setting up the buttons properly, like the onclick events, those are what makes the screens change :)

    • @TM-TM.
      @TM-TM. 5 месяцев назад

      @@garrettdeveloper Thanks I did resolve that problem but now i have another one, when i am in the pause menu everthing pauses exepect the camera i can still move the camera around does it have to do with the pause menu or just the personcontroller?

  • @benjib20
    @benjib20 Год назад +1

    Hey, I'm having an issue where when I left or right click (I have grapple hooks in the game so you would normally swing) It puts the mouse in the game and you need to press escape again to get the mouse back but it doesn't let me click the options. Is there any way to resolve this issue?

    • @ponffffes
      @ponffffes Год назад

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class PauseMenuScript : MonoBehaviour
      {
      public static bool Paused = false;
      public GameObject PauseMenuCanvas;
      // Start is called before the first frame update
      void Start()
      {
      Time.timeScale = 1f;
      }
      // Update is called once per frame
      void Update()
      {
      if (Input.GetKeyDown(KeyCode.Escape))
      {
      if (Paused)
      {
      Play();
      }
      else
      {
      Stop();
      }
      }
      }
      void Stop()
      {
      PauseMenuCanvas.SetActive(true);
      Time.timeScale = 0f;
      Paused = true;
      Cursor.visible = true;
      }
      void Play()
      {
      PauseMenuCanvas.SetActive(false);
      Time.timeScale = 1f;
      Paused = false;
      Cursor.visible = false;
      }
      public void MainMenuButton()
      {
      SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
      }
      } - use this code bro!

  • @Osoclever
    @Osoclever 10 месяцев назад +1

    Your awesome thank you

  • @Speed.Neo1120
    @Speed.Neo1120 Год назад +2

    yo bro can you please do a game over screen now all the other tutorials aren't as descriptive as yours

    • @garrettdeveloper
      @garrettdeveloper  Год назад +3

      Hello, that's a great idea. I've been wanting to make some more tutorials and I'm glad people like them! This is the first suggestion for a tutorial I've gotten so I'll put it on a list, thanks!

  • @TokenYT
    @TokenYT 10 месяцев назад

    When I hover over or click any of the buttons nothing happens.

  • @Deathgun2208
    @Deathgun2208 Год назад

    Wenn ich meinen Mauszeiger Bewege dann bewegt sich meine Player Kamera und wenn ich irgendwo draufklicken will lockt es meinen Mauszeiger im Game.

  • @chananayoro9152
    @chananayoro9152 Год назад +2

    when i press escape, the game freezes, but the pause menu doesn't pop up. Why?

    • @echiko4932
      @echiko4932 7 месяцев назад

      For people who face this issue in the future, double check u spelled everything right in the script. It basically says "when esc is pressed, enable this ui object". Remember caps sensitivity too.
      Ever since i spent 10mins tryna figure out why my "GetComponont" wasnt working im hawkeyeing these spellings

  • @PandexOnYT
    @PandexOnYT 6 месяцев назад

    the game doesnt frozes when i open the pause menu

  • @FNAFgorilla
    @FNAFgorilla Год назад +6

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class PauseMenu : MonoBehaviour
    {
    public static bool paused = false;
    public GameObject PauseMenuCanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    }
    // Update is called once per frame
    void Update()
    {
    if (input.Getkeydown(KeyCode.Escape))
    {
    if(paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }

    }
    }
    void Stop ()
    {
    PauseMenuCanves.setactive(true);
    Time.timescale = 0f;
    Paused = true;
    }
    void Play()
    {
    PauseMenuCanves.setactive(false);
    Time.timescale = 1f;
    Paused = false;
    }
    public void MainMenuButton()
    {
    SceneManger.LoadScene(something)
    }

    • @FNAFgorilla
      @FNAFgorilla Год назад

      Can someone help me its not working its the spacing i think

    • @FNAFgorilla
      @FNAFgorilla Год назад +2

      nvm i fixed it but the Void Stop() at 34 is not working said erorr code cs8803

    • @FNAFgorilla
      @FNAFgorilla Год назад

      i fiked it but there a Erorr CS0200

    • @FNAFgorilla
      @FNAFgorilla Год назад +1

      fixed again the scrpit has no erorrs but the menu still dosent work?

    • @LilSP33DFR3AK3RLIVE
      @LilSP33DFR3AK3RLIVE Год назад

      @@FNAFgorilla its giving me error CS1002

  • @prod.notchoppa
    @prod.notchoppa 8 месяцев назад

    When i got to main menu through the pause menu, it says "no cameras rendering" and the menu stops working. I have a player with a camera in the game scene, and no cameras in the main menu scene, how do i fix it?

    • @garrettdeveloper
      @garrettdeveloper  8 месяцев назад +1

      Hi, make sure every scene you are using has a camera, because this system changes scenes to manage a lot of the UI!

  • @ImTesto
    @ImTesto Год назад

    how do i fix the error where it says "You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings"?

    • @garrettdeveloper
      @garrettdeveloper  Год назад

      Hi, you need to go to your project settings and change your input system

  • @owen22s
    @owen22s Год назад +2

    how can i make it so it also stops playing the music?

    • @usmeet4812
      @usmeet4812 8 месяцев назад +1

      same question

    • @garrettdeveloper
      @garrettdeveloper  8 месяцев назад

      Hi, you can add another function on the pause method which references your audio player and calls it to pause, and then play on resume method

  • @benjib20
    @benjib20 Год назад

    To my previous statement, I have resolved half the issue. Now the mouse cursor doesn't disappear but I still can't hit the buttons. Please help

    • @echiko4932
      @echiko4932 7 месяцев назад

      Cursor.visible = false;
      In the play function.

  • @GregoryJoe4152
    @GregoryJoe4152 10 месяцев назад

    I'm having an issue, I've followed everything correctly but i think its my player moving around while I'm in the pause menu is causing it not to work

    • @GregoryJoe4152
      @GregoryJoe4152 10 месяцев назад

      It has something to do with my movement script, I have to somehow disable it while the pause menu is active.

    • @garrettdeveloper
      @garrettdeveloper  10 месяцев назад

      Hi, yeah you can reference your player movement script on the OnPause event and set it as disabled and enabled

  • @VinixVR
    @VinixVR 2 года назад

    so I remember your fix oculus vids I need help with mine so whenever I log on to my oculus it seems normal but the home page/store it automatically y scrolls down when I play a game my character moves backwards automatically how do you fix this?

    • @garrettdeveloper
      @garrettdeveloper  2 года назад +1

      Sounds like your oculus controller is stuck srolling down or holding a key down, you could try taking the battery out and restarting it, or try another controller!

    • @EstaticYT
      @EstaticYT 2 года назад +1

      thats joystick drift

  • @Silly-insect
    @Silly-insect Год назад +1

    i dont see the "Pause Menu Canvas" in the Pause Menu (Script)

    • @UnderatedClock
      @UnderatedClock 5 месяцев назад

      In the begining, he added this line of code "public GameObject PauseMenuCanvas;", so that we can use the canvas! hope this helps!

  • @bonse2000
    @bonse2000 Год назад

    the cursor lock dsnt work when I click on resume or options or quit the mouse disappears and i cant prerss on the buutoms but if i die in my game then my game over ui pop up and then i can press on the play options quit button so thats mean i have to everything right just i need in my script something for the cursor i think
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class PauseMenu : MonoBehaviour
    {
    public static bool Paused = false;
    public GameObject PauseMenuCanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    PauseMenuCanvas.SetActive(false);
    }
    // Update is called once per frame
    void Update()
    {
    if(Input.GetKeyDown(KeyCode.Escape))
    {
    if(Paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }
    }
    void Stop()
    {
    PauseMenuCanvas.SetActive(true);
    Time.timeScale = 0f;
    Paused = true;
    Cursor.visible = true;
    }
    public void Play()
    {
    PauseMenuCanvas.SetActive(false);
    Time.timeScale = 1f;
    Paused = false;
    Cursor.visible = false;
    }
    public void MainMenuButton()
    {
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
    }

    • @Marlit0o
      @Marlit0o Год назад

      thanks

    • @thingsnhfiujng
      @thingsnhfiujng Год назад

      i know im 6 months late, but i have a script that i did make with chatgpt because im not good at C# but it makes it so whenever you press esc it makes it so you can move it wherever you want and when you press it again, it locks the mouse again
      here it is:
      using UnityEngine;
      public class MouseToggle : MonoBehaviour
      {
      private bool isCursorLocked = true;
      private void Update()
      {
      if (Input.GetKeyDown(KeyCode.Escape))
      {
      isCursorLocked = !isCursorLocked;
      if (isCursorLocked)
      {
      StartCoroutine(ToggleCursorLock());
      }
      else
      {
      StopCoroutine(ToggleCursorLock());
      Cursor.lockState = CursorLockMode.None;
      Cursor.visible = true;
      }
      }
      }
      private System.Collections.IEnumerator ToggleCursorLock()
      {
      while (true)
      {
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.visible = false;
      yield return new WaitForSeconds(0.1f); // Adjust the delay as needed
      Cursor.lockState = CursorLockMode.None;
      Cursor.visible = true;
      yield return new WaitForSeconds(0.1f); // Adjust the delay as needed
      }
      }
      private void Start()
      {
      // Start with the cursor locked
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.visible = false;
      }
      }

  • @dex4075
    @dex4075 2 года назад

    at 9:59 im getting an error that says CS1061:'GameObject' does not contain a definition for 'setActive'

  • @sherlockholmes374
    @sherlockholmes374 Год назад

    I have buttons already and they somehow are over my pause menu. How can I change this?

    • @garrettdeveloper
      @garrettdeveloper  Год назад

      Hi! It has to do with how you place the buttons and layers. Try placing the buttons on the same canvas/panel as the pause menu and make it all under one canvas

  • @Guts-King1
    @Guts-King1 9 месяцев назад

    Could you tell me why it doesn't work, is it because of the script that makes my character move?

    • @garrettdeveloper
      @garrettdeveloper  9 месяцев назад

      Hi, it depends on many factors but yes first make sure the script is correct by following the video!

  • @miaw1232
    @miaw1232 2 года назад

    It doesnt work when i go to the next level, i copy paste it and the button is not clickable

  • @yeet-man9080
    @yeet-man9080 Год назад

    Hey I have been running into a problem, I have managed to follow every step. Everything works except for when I click the "Main Menu" button on the pause screen, I go back to the main menu but I cannot click anything.

    • @DeagleAssault
      @DeagleAssault Год назад +1

      did u watch his last tut?

    • @CatWithThumb
      @CatWithThumb Год назад

      Same issue here if anyone knows a way to fix it

    • @WRyder_D
      @WRyder_D Год назад

      put a mouse unlock script on an empty object and call it MouseUnlock and make sure its in the main menu scene

    • @WRyder_D
      @WRyder_D Год назад

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class MouseUnlock : MonoBehaviour
      {
      // Start is called before the first frame update
      void Start()
      {
      UnlockMouse();
      }
      // Update is called once per frame
      void Update()
      {

      }
      void UnlockMouse()
      {
      Cursor.lockState = CursorLockMode.None;
      Cursor.visible = true;
      }
      }

  • @LeatherBootsJohnson
    @LeatherBootsJohnson 2 года назад +1

    Thank you

  • @-_.k._-
    @-_.k._- Год назад +1

    so awesome

  • @sherlockholmes374
    @sherlockholmes374 Год назад

    What do I do if my options menu is an entirely new scene?

    • @garrettdeveloper
      @garrettdeveloper  Год назад

      Hi, I don't think you'd want your pause menu options to be another Unity scene, because you'd need to use Scene management.loadScene and when you go back into the game scene everything would restart. I would suggest taking the features of your options menu and adding them into your in-game main menu

  • @Lokonytofficial
    @Lokonytofficial 2 года назад

    its not showing me the pause menu on the Functions

  • @grim6780
    @grim6780 Год назад

    I cant add the script to my menu manager

  • @goopy_GT
    @goopy_GT 5 месяцев назад

    How do I save using visual studio

    • @garrettdeveloper
      @garrettdeveloper  5 месяцев назад

      Hi, saving is very important. Ctrl + S to save, or file>save :)

  • @bolivarrenz2615
    @bolivarrenz2615 Год назад +1

    bro this can also work in a multiplayer?

    • @garrettdeveloper
      @garrettdeveloper  Год назад

      Yes, for example with Photon Pun2 it'll work fine you just have to sync the canvas with the player

  • @Starboyyyy98
    @Starboyyyy98 Год назад

    i got so much freaking errors :C how fix?!?Q??!

  • @EstaticYT
    @EstaticYT 2 года назад +1

    will this work with multiplayer or what happens if i pause

    • @garrettdeveloper
      @garrettdeveloper  2 года назад

      Yes this will work with multiplayer! The menu object just has to be part of a networked player prefab

  • @skylue1524
    @skylue1524 7 месяцев назад +1

    Nice tutorial but i'd rather listen to you rather than the background song :p

    • @garrettdeveloper
      @garrettdeveloper  7 месяцев назад +1

      Thanks! Yeah I've been working on making the background music quieter, sorry about the past editing mistakes 😅 thanks for the feedback

  • @LilSP33DFR3AK3RLIVE
    @LilSP33DFR3AK3RLIVE Год назад

    the script is not working

  • @0.ENMITY
    @0.ENMITY 11 месяцев назад

    it keeps saying that it needs ;
    wth

    • @garrettdeveloper
      @garrettdeveloper  11 месяцев назад

      That means at the end of your statements, you need to add a semicolon. So add ; to the end of your statements, you can also see where they go in the video!

    • @0.ENMITY
      @0.ENMITY 11 месяцев назад +1

      @@garrettdeveloper i probably was too slow so i didnt notice that you put that there
      lol

  • @_Pollard_
    @_Pollard_ Год назад

    @Dylan_Developer What Does It Mean When I Get An Error Saying "The name paused does not exist in the current context"

    • @garrettdeveloper
      @garrettdeveloper  Год назад

      It means you haven't defined what the name "Paused is", in this case it is a boolean. In my script on line 8, I defined Paused as "public static bool Paused = false" so that we can set the Paused function with the script. Hope this helps!

  • @lefoudegaming1233
    @lefoudegaming1233 Год назад

    How do I convert the "Input.GetKeyDown(KeyCode.Escape))" but for the NEW INPUT SYSTEM ?

  • @Coolkidstan
    @Coolkidstan Год назад

    my code isnt working i dont know why if its something stupid i only just started coding
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class NewBehaviourScript : MonoBehaviour
    {
    public static bool paused = false;
    public GameObject PauseMenucanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    }
    // Update is called once per frame
    void Update()
    {
    if (input.Getkeydown(KeyCode.Escape))
    {
    if(paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }

    }
    }
    void Stop ()
    {
    PauseMenucanvas.setactive(true);
    Time.timescale = 0f;
    Paused = true;
    }
    void Play()
    {
    PauseMenucanvas.setactive(false);
    Time.timescale = 1f;
    Paused = false;
    }
    public void MainMenuButton()
    {
    SceneManger.LoadScene("Main menu");
    }

    • @big_ell123
      @big_ell123 Год назад +2

      On SceneManger.LoadScene("Main menu"); you put SceneManger when its SceneManager

    • @Coolkidstan
      @Coolkidstan Год назад

      @@big_ell123 thanks for the help

    • @big_ell123
      @big_ell123 Год назад +1

      @@Coolkidstan no problem

  • @metinbatuhanozucan5358
    @metinbatuhanozucan5358 Год назад +1

    Thank you

  • @AMINEI-wl9rk
    @AMINEI-wl9rk 2 месяца назад

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class PauseMenu : MonoBehaviour
    {
    public static bool paused = false;
    public GameObject PauseMenuCanvas;
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1f;
    }
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.Escape))
    {
    if (paused)
    {
    Play();
    }
    else
    {
    Stop();
    }
    }
    }
    void Stop()
    {
    PauseMenuCanvas.SetActive(true);
    Time.timeScale = 0f;
    paused = true;
    }
    public void Play()
    {
    PauseMenuCanvas.SetActive(false);
    Time.timeScale = 1f;
    paused = false;
    }
    public void MainMenuButton()
    {
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
    }