GameObject Wont' Set Active,Set active doesn't work trying to do something simple.

I’ve been working on this for quite a long time. I’m familiar with unity but working on my C# skills. These seem like they should be simple actions to do, but after days and nights looking at this script, it won’t work.

All I’m trying to do is display a scene with an active object, then show it for 40 seconds, hide it, and show a new object.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoadWeatherShelf : MonoBehaviour {

    //Todo
    //Hide Object 1 after 40 seconds
    //Display A new object


    // Use this for initialization
    void Start () {

        Invoke("NextObject", 40);
        
    }
	
	// Update is called once per frame
	void Update () {
		
	}

    void NextObject ()
    {
        GameObject.Find("PrimarySceneContent").SetActive(true);


    }

Any help is appreciated!

,I spent a lot of time working on this nights and days and hours and still can’t get this to work right. It’s some dumb mistake I’m sure.

I’m simply trying to deactivate one object (not destroy), after a set duration 40seconds, and then turn on another object that is de-activated. I’ve tried so many varieties. Nothing works.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoadShelf : MonoBehaviour {

    //Todo
    //Hide Object 1 after 40 seconds
    //Display A new object


    // Use this for initialization
    void Start () {

        Invoke("NextObject", 40);
        
    }
	
	// Update is called once per frame
	void Update () {
		
	}

    void NextObject ()
    {
        GameObject.Find("PrimarySceneContent").SetActive(true);


    }

The problem is you’re trying to find an object which is already inactive in the scene. So you should be getting a NullReferenceException after 40 seconds. So what you want to do is to have a reference of the object you want to activate in the script already instead of trying to find it using GameOject.Find. You can modify your script as follows :

public GameObject objectToActivate ;

And in your NextObject method :

     void NextObject ()
     {
         objectToActivate.SetActive(true);
     }