Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: justinISO on October 22, 2013, 01:04:28 PM

Title: Increase/Decrease depth of all widgets in a panel
Post by: justinISO on October 22, 2013, 01:04:28 PM
Hello,

I have a card type game I am using NGUI for and the cards are set up as follows:

Card One - Panel
-- BG - Sprite
-- Info - Label
-- Title - Label

All cards are laid out like this.

What I need is when I hover over a single card, I increase it's size to make it look like it is coming forward (this is already working), but I also need to bring the depth of everything (labels and sprites) of that single card ahead of all of the other cards on the table at the same time.

Any thoughts?

Thanks,
Justin
Title: Re: Increase/Decrease depth of all widgets in a panel
Post by: NaxIonz on October 22, 2013, 01:58:35 PM
Bring them all forward:

  1. UIWidget[] widgets = gameObject.GetComponentsInChildren<UIWidget>();
  2. foreach (UIWidget widget in widgets) {
  3.   widget.depth += 1;
  4. }
Title: Re: Increase/Decrease depth of all widgets in a panel
Post by: justinISO on October 22, 2013, 03:17:02 PM
Thank you!

Interesting note. I was trying to do the GetComponentsInChildren in the line of the foreach

  1. foreach(UIWidget widget in gameObject.GetComponentsInChildren<UIWidget>()){
  2. .
  3. .
  4. .

And that was throwing an error saying UIWidget was not Enumeratable or something along those lines. Which is why I brought this to the forums.

Your way works though so thanks!

~Justin