Exception while trying to spawn objects at runtime

Hi, while working with unity, I get a “null reference exception Object reference not set to an instance of an object” error.

I got this method inside the “SpawnObjects” class :

public class SpawnObjects : MonoBehaviour
{
public GameObject[] RandomGO;

public void spawnSomeObjects()
{
GameObject Gobj = Instantiate(RandomGO[0]) as GameObject;
Gobj.transform.position = new Vector3(0f, 50f, 5f);
}

}

After setting the lenght of the array and after placing the objects in it from the inspector, I try to call this method from the Update function of this other class :

public class BucketMovement : MonoBehaviour {

public float AssignTimeSpawn = 2.0f;
float TimeSpawn = 2.0f;
SpawnObjects So;

void Start()
{
So.GetComponent<SpawnObjects>();
}

void Update ()
{
TimeSpawn -= Time.deltaTime;
if (TimeSpawn < 0)
{
TimeSpawn = AssignTimeSpawn;
So.spawnSomeObjects();
}
}

And as I said, I get that null reference exceptions… question : if I set field members to public static, why they wont appear in the inspector?

I cannot use the gameobject.find( “” ).getcomponent solution since the object that i’m looking to call will be instantiated at runtime, after the selected timelapse, and will still give me the same error

line 5 is never asigned to, as far as i see. And to the public static, just omit the static.

What you could try is a Singleton, which the instantiated objects register to, when they spawn.

I somehow found a solution usign the GameObject.FindObjectOfType< > Anybody knows why exactly this worked and the possible other uses of it ?