Dictionary in second script empty

Hi guys,

I have a dictionary in script A that is part of a prefab which will included in script B. All key/value pairs are set in the start method of script A and I also can access them in this method.

In the second script I access the dictionary with gameobject.GetCompontent<scriptA>().dict but the dictionary is always empty.
I am realy confused. I thought it would be the late initialization but the update method shows the empty dictionary on each frame.

Thanks a lot!

Class A with the directory.

public class ScriptA : MonoBehaviour
{

	public Dictionary<string, int> dict = new Dictionary<string, int>();

	// Use this for initialization
	void Start ()
	{
		dict.Add("key1", 888); 
		dict.Add("key2", 999); 
	}
	
}

Class B that holds an array of gameobjects. The gameobjects contains ScriptA.

public class ScriptB : MonoBehaviour
{
	public GameObject[] Container;

	// Use this for initialization
	void Start () {
		Debug.Log(Container[0].GetComponent<ScriptA>().dict.Count);
	}
}

Is Container[0] referencing the prefab? If you don’t Instantiate the object, the Start function will never run on it.