Author Topic: Dynamically create a button  (Read 2153 times)

AllanZinyi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Dynamically create a button
« on: March 03, 2014, 02:41:15 AM »
I'm new in both NGUI and unity.
I do not know how to apply Atlas and Sprite on the button I have created dynamically.
By the way, I'm using c#.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically create a button
« Reply #1 on: March 04, 2014, 12:27:19 AM »
A button can be anything with a collider. Assuming you are talking about one of NGUI's stock controls, a button there is a UISprite for the background and a UILabel for the text. To get one of them, you can simply use GetComponent / GetComponentInChildren like any other script.