Author Topic: collider not disabled when disable UIPanel  (Read 7976 times)

realblues

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
collider not disabled when disable UIPanel
« on: May 01, 2012, 08:04:40 AM »
My Panel has several widgets like button, Inputs..

and several Panel exists in same position, it's visible only one Panel by situation.

to hide it, i use UIPanel.enabled, then images hide but collider still enabled, so new widgets not triggering well.

isn't it right way? should i use NGUITools.SetActive()?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: collider not disabled when disable UIPanel
« Reply #1 on: May 01, 2012, 08:05:16 AM »
Yeah, use NGUITools method. It will hide all children as well.

realblues

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: collider not disabled when disable UIPanel
« Reply #2 on: May 01, 2012, 08:15:59 AM »
Thanks for Quick reply :)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: collider not disabled when disable UIPanel
« Reply #3 on: May 01, 2012, 09:06:32 AM »
Or use SetActiveRecursively(gameObject, true/false).

Difference with NGUITools.SetActive is that the NGUI version affects parents first, and the built in affects children first.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: collider not disabled when disable UIPanel
« Reply #4 on: May 01, 2012, 09:08:36 AM »
Depends on whether it's 'true' or 'false', Nicki. When enabling, parents are enabled before children. When disabling, children are disabled before parents.

Unity's built-in version doesn't do this, and always enables and disables in the same order, which can produce some odd effects.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: collider not disabled when disable UIPanel
« Reply #5 on: May 01, 2012, 10:04:05 AM »
Ah, I did not know that you change the order based on that.

Nonetheless, both can produce odd effects when you don't know (or expect) the behavior of it. :D