title: Button.onClick.AddListener() not working as intended
body: <p>I've been struggling with this for the last couple of hours.
  I can access and edit the properties of the button, but the onClick.AddListener() function does not work. Here is my code:</p>
  <pre><code>GameObject gameObject;
          gameObject = Resources.Load(&quot;Prefabs/MenuOption&quot;) as GameObject;
  
          gameObject.GetComponent&lt;Image&gt;().sprite = Resources.Load&lt;Sprite&gt;(option.imgPath);
  
          Button button = gameObject.GetComponent&lt;Button&gt;();
  
          // Testing to see if I can change button properties (works)
          ColorBlock colorss = button.colors;
          colorss.highlightedColor = Color.magenta;
          button.colors = colorss;
          
          // This does not work
          button.onClick.AddListener(() =&gt; Test(button));
          button.onClick.AddListener(() =&gt; { Debug.Log(&quot;click&quot;); });
  
          Instantiate(gameObject, pos, new Quaternion(), GameObject.Find(&quot;Canvas&quot;).transform);
  </code></pre>
  <p>And here is an instance of the prefab:
  <a href="https://i.stack.imgur.com/GjzB3.png" rel="nofollow noreferrer">image</a></p>
  <p>If anyone knows what I'm doing wrong, I would be very grateful.</p>