playMaker

Author Topic: [SOLVED] Removing/Destroying Children from NGUI UI Grid  (Read 4037 times)

memetic arts

  • Full Member
  • ***
  • Posts: 141
[SOLVED] Removing/Destroying Children from NGUI UI Grid
« on: November 08, 2015, 11:37:12 AM »
Hello, Happy Sunday . . . next chapter in the travails of creating a drill-down style menuing system . . .

I'm successfully generating dynamic lists via a hashtable. I now need to change the list items based on various button clicks, so that when I click on button 1, items 1.1, 1.2, 1.3 will display, and when I click on button 2, items 2.1, 2.2, 2.3, etc. will display.

I'm using NGUI, and the NGUI Tools AddChild action, to instantiate the pre-fabbed buttons that comprise the list. As there is no RemoveChild action, I've attempted to use GetNextChild and destroy the child objects. In the GetNextChild action, I'm assigning each child object to a local variable (called "childObj"), and, in the next state, am using a DestroyObject action that calls the childObj variable.

The problem is that it gets as far as the DestroyObject action, destroys the first child, and then hangs, e.g. never completes the first loop. I've tried it with lists of both one and many objects, and the result is the same.

The strange thing, which I've highlighted in red, is that the variable assignment doesn't seem to be reflected in the Destroy action, eventhough the first item is actually destroyed -- so it must be registering somewhere.

I'm going to keep banging on it, of course, but any insight would be appreciated!

Thanks,

Richard



« Last Edit: November 08, 2015, 08:23:49 PM by memetic arts »

memetic arts

  • Full Member
  • ***
  • Posts: 141
[SOLVED] Removing/Destroying Children from NGUI UI Grid
« Reply #1 on: November 08, 2015, 08:23:19 PM »
W00T! Solved this one myself.

For the possible benefit of others, my solution was to send a global event to each subsequent item from the GetNext loop, and upon receiving the event, to have the item destroy itself.

Thanks to this post for triggering the idea:

http://hutonggames.com/playmakerforum/index.php?topic=4717.0

Sounds like the evening news, but in the land of PlayMaker, Global Events that lead to Self-Destruction are a good thing!

Cheers
« Last Edit: November 08, 2015, 08:28:26 PM by memetic arts »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: [SOLVED] Removing/Destroying Children from NGUI UI Grid
« Reply #2 on: November 09, 2015, 01:40:36 AM »
Hi,
thanks for sharing your solution.