- Home /
(C#) SetActive isn't working on my UI
So, my script that i've written isn't working fully. I have A pause button and when I press it, it triggers my bool and shows that its working properly but when i'm "Paused" my UI doesn't pop up and my game doesnt stop in the back ground. I hope you can understand clearly. I am a beginner!
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class PauseManager : MonoBehaviour {
public GameObject pauseMenu;
public bool paused = false;
public void start()
{
pauseMenu.SetActive(false);
}
public void update()
{
if(Input.GetButtonDown("escape"))
{
paused = !paused;
}
if (paused)
{
pauseMenu.SetActive(true);
Time.timeScale = 0;
}
if (!paused)
{
pauseMenu.SetActive(false);
Time.timeScale = 1;
}
}
public void Resume()
{
paused = false;
}
public void pauseButton()
{
paused = true;
}
}
as roland_k said uese capital U for Update()
& no need to Update()
to bee public & for stop in the back ground you have to Quit your app :
if(Input.GetButtonDown("any button")){
Application.Quit();
}
Answer by $$anonymous$$ · Apr 18, 2016 at 02:31 PM
You might want to change your update function into: public void Update()
The difference is the capital U.
Answer by FM-Productions · May 02, 2017 at 05:58 PM
The answer of roland_k is correct. However, I want to add that you will have the same problem with the start function. Write it with a capital S -> void Start(). Otherwise, Unity itself probably won't execute the function.
Your answer
Follow this Question
Related Questions
Bullets follow the ship in 2D Space Shooter game 2 Answers
Collider not registering hits? 4 Answers
Hello can anyone help me in my code i am converting some code JS to C# 1 Answer
Add more seconds to the timer when colliding with an object. 2 Answers
Selecting an ability based on UI image/button, and thereafter selecting a target for the ability 0 Answers