Author Topic: How to create Image buttton DYNAMICALLY  (Read 4277 times)

basil_11

  • Guest
How to create Image buttton DYNAMICALLY
« on: October 16, 2012, 09:25:17 PM »
I'm new in NGUI and I want to create UIImageButton Dynamically after clicking a Button.

can you please give me some tips or sample codes on how to do it thanks!!!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to create Image buttton DYNAMICALLY
« Reply #1 on: October 17, 2012, 02:11:53 AM »
You add the relevant components and collider to the gameobject you want to become a button.

Or you use NGUITools.AddChild with a reference to a prefab where you have designed the button already.

basil_11

  • Guest
Re: How to create Image buttton DYNAMICALLY
« Reply #2 on: October 17, 2012, 02:30:48 AM »
Thanks for the tips.. can you give me some Sample scripts? I'm just new in NGUI :)

Creating a UIImageButton using a program/Script

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to create Image buttton DYNAMICALLY
« Reply #3 on: October 17, 2012, 04:21:57 AM »
Make one with the widget tool (top menu: NGUI->Create a widget) and see what components it puts on it, then you can recreate the same in code with a helper script.

Or look at the examples provided with the package.