- Home /
Question by
Poskoloko · Jun 11, 2018 at 03:25 PM ·
scripting problemsetactive
Unity SetActive() doesn't activate object
I have a problem that I can't solve by my self.
I have a Pause Button which need to activate pause panel on scene, but nothing work. 1. I have a public GO "Panel" attached in the inspector. 2.Inspector writes that: "There is no 'GameObject' attached to the "Panel" game object, but a script is trying to access it." 3.Script on always active GO. 4.At start Panel is Active.
> public class ButtonController : MonoBehaviour {
private Scene ActiveScene;
private GameController gm;
public GameObject panel;
// Use this for initialization
void Start ()
{
gm = GetComponent<GameController>();
ActiveScene = SceneManager.GetActiveScene();
panel.SetActive(false);
}
public void Pause()
{
Debug.Log("Pause");
panel.SetActive(true);
Time.timeScale = 0;
}
public void Menu()
{
SceneManager.LoadScene(0);
}
public void Restart()
{
SceneManager.LoadScene(ActiveScene.buildIndex);
}
public void Play()
{
Time.timeScale = 1;
panel.SetActive(false);
}
Glad if u can help!
Comment
Your answer
Follow this Question
Related Questions
Both IF statements in a function are run and their conditions are ignored. 4 Answers
Make a gameobject inactive and active 0 Answers
SetActive() not working 0 Answers
need help with armor customization 1 Answer
physics.OverlapSphere colliders 1 Answer