1

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.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

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!

5
  • Do this question in Game Development of Stack Exchange. Commented Jun 11, 2018 at 14:57
  • Thank you, done! Commented Jun 11, 2018 at 15:05
  • 3
    @AAShakil: Please, stop redirecting people on Game Development for any question about Unity. It is absolutely legit to ask here, if they're about programming. Commented Jun 11, 2018 at 15:37
  • @Andreaジーティーオー I was trying to help him to get better answer. Commented Jun 11, 2018 at 18:03
  • 1
    @AAShakil GameDev SE actually has less traffic than the [unity3d] tag on SO. Plus, crossposting the question on Game Dev and SO is discouraged. Commented Jun 12, 2018 at 3:57

1 Answer 1

0

I solved the problem: I attached the script twice.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.