I have a GameObject BG, I want it to turn off when the Toggle changes.
private GameObject BG; // Use this for initialization void Start () { BG = GetComponent<GameObject>(); } // Update is called once per frame void Update () { } public void SetTheme(bool newValue) { BG.SetActive(!BG.activeSelf); } But this code does not work. Gives such an error:
MissingComponentException: There is no need for a game. You probably need to add a GameObject to the game object "BG". If your component needs to be checked before using it.
Although the project has Panel BG