title: C# Unity Wrong argument of the function in onClick event
body: <p>When I'm adding methods to <code>onClick</code> buttons the argument of the function is always <code>const = array of buttons.length + 1</code>.  Where did I go wrong?</p>
  
  <p><code>all_buttons</code> not empty. I clicked on three different buttons.
  Unity log screenshot: <a href="https://s12.postimg.org/ijk2y26rh/T6uh_Xda_Uv_JI.jpg" rel="nofollow">link</a></p>
  
  <pre><code>Button[] all_buttons = GetComponentsInChildren&lt;Button&gt;();
  for (int i = 0; i &lt; all_buttons.Length; i++) {
      Debug.LogWarning(all_buttons[i]+" =&gt; addLoad with index "+ (m_LvlStartIndex + i));
      if (levelScript)
          all_buttons[i].onClick.AddListener(() =&gt; Load(m_LvlStartIndex+i));
  }
  
  public void Load(int level) {
      Debug.LogWarning("Loading "+level+" level...");
      Application.LoadLevel(level);
  }
  </code></pre>
  
  <p>Update:
  change this </p>
  
  <pre><code>all_buttons[i].onClick.AddListener(() =&gt; Load(m_LvlStartIndex+i));
  </code></pre>
  
  <p>to</p>
  
  <pre><code>int tempI = i;
  all_buttons[i].onClick.AddListener(() =&gt; Load(m_LvlStartIndex+tempI));
  </code></pre>
  
  <p>Thanks to all!!</p>