title: Public Dictionary in Unity
body: <p>how I can make public Dictionary, what i use in other script and object in Unity? I have Dictionary in Object and script <strong>A</strong> and i want add values to this Dictionary with command in script/object <strong>B</strong>. </p>
  
  <p>*For example A script in A object: *</p>
  
  <pre><code>public Dictionary&lt;string, GameObject&gt; dictio  = new Dictionary&lt;string, GameObject&gt;();
  </code></pre>
  
  <p>*For example B script in B object: *</p>
  
  <p>A: </p>
  
  <pre><code>public Dictionary&lt;string, GameObject&gt; obstacleDictionary;
  
  GameObject gob;
  
  void Start()
  {
      obstacleDictionary = new Dictionary&lt;string, GameObject&gt;();
      pos = transform.position;
  
  }
  </code></pre>
  
  <p>B: </p>
  
  <pre><code>Vector3 pos;
      public string openSide;
      GameObject player;
      string posString;
  void Start ()
  {
      player = GameObject.FindGameObjectWithTag("Player");
      pos = transform.position;
      posString = pos.x + "_" + pos.y;
  
  
      player.GetComponent&lt;PlayerMove&gt;().obstacleDictionary.Add(posString, gameObject); //warning
  
      //print(player.GetComponent&lt;PlayerMove&gt;().obstacleDictionary.ContainsKey("3_0"));
  }
  
  A.GetComponent&lt;AScript&gt;().dictio.Add("aaa", gameObject);
  </code></pre>
  
  <p>Can you help me? Thanks :)
  <a href="https://i.stack.imgur.com/jN2NF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jN2NF.png" alt=""></a></p>