Комментарии:
Edit: Managed to get this done. If ya got any qns, drop one here. I'll try to help.
For anyone stuck at the very first step of making the button Tint on hover - go to your "Button" inspector, look for "Navigation". There should be a [Visualise] button, make sure it's not blue. See if that helps.
A funny bug I found: if you spam the jump button while paused, you will go flying in the air when you resume hahah. This is easily fixed by disabling the player controller when paused and then enabling when resumed.
Like this: "player.GetComponent<PlayerController>().enabled = false"
I just realized he kinda sounds like da vinki
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Menu");
}
public void QuitGame()
{
Debug.Log("Quitting game...");
Application.Quit();
}
}
Thank you. This video really helps me
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
}
void Resume()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
}
Ok when I click the play button the screen is still there until I click the pause button, it’s a minor inconvenience but how do I fix but this is the only problem every thing else work perfectly fine
Ответитьhey, I'm having an issue where when I start the game the pause menu is there too, like when I play the game the pause menu shows up immediately. I mean I can press escape but I do not want the pause menu to show up every time I load the game :/ If anyone has any advice for this I would greatly appreciate it.
Ответитьif anyone is stuck when they want a different button to load different scenes then replace the LoadScene() function with the code below:
public void LoadMenu(string sceneIndex)
{
Time.timeScale = 1f;
SceneManager.LoadScene(sceneIndex);
}
FU
ОтветитьWhat would be the best way to have the same pause menu for several scenes? (Game level 1, level 2 etc...) making a prefab from the menu canvas? or making an own menu scene and loading with SceneManager additive?
ОтветитьFor those that is having problem with uniteractable button
Make sure your Canvas habe Graphic Raycaster to the setting is default so you don't need to edit it at all
you need to make sure that you give the scene a EventSystem
-RightClick in your project where you usually add text/button
-Then go to UI, EventSystem will be at the bottom of it
The button is not responding for me
ОтветитьHey, i really like your videos and the helped me out a lot, but one question for the guys in the comment section, in my first scene, the pause menu works fine, but when i copy / paste it to other scene, it doesnt work so well
what can i do?
can someone provide the full code of the pause menu please
ОтветитьIt's mind blowing how Brackeys videos stay relevant and work so well 6 YEARS LATER. Making games is a daunting task but this content has made the learning curve so much smoother! Thank you for sharing so much knowledge with the indie game dev community. 🙏🙏🙏
ОтветитьWhenever i pause my game and the ui shows up, i cant move my mouse. how do i fix this?
Ответитьthe code just randomly gave me 4 errors
ОтветитьAnd what happens if I have boolean parameters in my animations, and when I pause the game, they get deactivated?
Ответитьfrom 2d to 3d?
ОтветитьThank YOU SO MUCH BRACKEY
-Jotaro
Please someone help i don´t see cursor when i build it but if i play in unity i see it
Ответитьin 2023 I see This Turtual
This is increadable 🔥🔥
It was great explain
ОтветитьWhen I load the main menu, the buttons on the main menu stop working, anyone know a fix?
Nvm, just had to unlock the cursor xd
but how can i make it if i have different levels in my game and they are in different scenes
Ответитьfor the Resume() function use this in the beginning:
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
for the Pause() function use this in the end:
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
your welcome ;)
guys if your pause menu isnt working please that the script isnt in the PauseMenu panel because since its disabled scripts inside it wont work or run, so make sure you add the script onto the canvas lol,
Ответитьhow to move in planet like this video?
ОтветитьAnyone who can help me? I followed the instructions of the video, and the buttons won't highlight on hovering, nor they'd change color on click. I have an event manager and the buttons are set on interactable. What could the issue be?
Ответить2023 and Brackeys is still saving my arse.
ОтветитьHelp there is something wrong. unity is not recognizing my inputs
ОтветитьDoes anyone know how to make the camera freeze in an FPS game? (I have the timescale set to 0 btw). Would someone be able to help me?
Here's the code if it helps (I don't have a menu, so I left that out):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
UnlockMouse();
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void QuitGame()
{
Debug.Log ("Quitting Game!");
Application.Quit();
}
void UnlockMouse()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
Edit: The movement I'm using is from Unity's First Person preset.
Works like a charm
ОтветитьI just figured out if you have:
Cursor.lockState = CursorLockMode.Locked;
in your code, it makes the buttons not react to clicks/hovering.
I feel so stupid but just in case there's anyone else out there with the same problem I have to leave this comment :D
does anyone have the same problem as me when you load menu and and load a level, need to press esc twice the first time in order for the pause menu to appear
Ответитьusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Menu");
}
public void QuitGame()
{
Debug.Log("Quitting game...");
Application.Quit();
}
}
omg i struggled at this one and this is 2d this doesn't help though that is my fault for thinking that it is THAT simple
well i spent a good 2~3 hours researching why and how and what but already i learned new things
When i press the menu button my particle system in the menu doesn't start. Someone knows hwo to fix it?
ОтветитьHey guys can you help me? I'm creating megaman style game and my problem is when the game paused, the player still can shoot.
ОтветитьYou are the best Unity explainer.
Ответитьthank you, so helpful
ОтветитьI don't have a button only button - text neshg or what
ОтветитьHow do I fix error cs0106?
ОтветитьLevel 1 menus work with the pause and resume however when I create a menu level 2 deep the pause and resume no longer work, even if I used unscaled time for the button.
Ответитьits 11:59pm, i started work and 10 am thank you so much for these videos, i don't want to imagine how long it would've taken if i did it cold turkey!
ОтветитьDoes anyone know how to pause the audio while the game is paused
ОтветитьIn my 2d game i've implemented this pause menu , but i when click the menu button the particles in the main menu doesn't start even the transition to the game scene (from the menu scenes). Someone can help? Thanks!!
Ответить