Author Topic: Dynamically create draggable buttons (on panel) at runtime  (Read 3620 times)

Teku Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
    • Teku Studios
Dynamically create draggable buttons (on panel) at runtime
« on: March 19, 2013, 10:15:55 AM »
Hi there!

We are developing a 2D sidescrolling adventure, and we are currently dealing with an inventory system. For gameplay purposes, we have a "quick" inventory that shows up on certain spots where the player can use one of his items. That quick inventory is a small panel at the bottom of the screen that contains a buttons Grid, and when the player presses left & right the icons scroll to center the one that's selected. Well, here comes the trouble.

If the item list is static (all the buttons are within the Hierarchy before hitting Play), everything works fine. However, if we read the Inventory list from script and create the quick inventory panel dynamically with all the item icons updated at runtime (we use NGUITools.AddChild), the controls don't work at all. Is that a problem with the Draggable Panel, or with the button grid? Must we do things differently?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically create draggable buttons (on panel) at runtime
« Reply #1 on: March 19, 2013, 09:57:46 PM »
Did you reference the draggable panel on your instantiated items?

Teku Studios

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
    • Teku Studios
Re: Dynamically create draggable buttons (on panel) at runtime
« Reply #2 on: March 20, 2013, 04:06:01 AM »
Yes, in all of them.