title: How to dynamically create button using NGUI (Unity)
body: <p>I'm new in both unity and NGUI, I couldn't figure how to assign custom atlas and sprite into the button dynamically. </p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class createButton : MonoBehaviour {
      public createButton(){
          GameObject newButton = new GameObject ();
          newButton.name = "newButton" + 1;
  
          //go.AddComponent&lt;UISprite&gt; ();
          newButton.AddComponent&lt;UIButton&gt; ();
          newButton.AddComponent&lt;UISprite&gt; ();
      }
  }
  </code></pre>