Author Topic: Widget SetAlpha = 0 vs SetActive(false)  (Read 3618 times)

Genhain

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Widget SetAlpha = 0 vs SetActive(false)
« on: October 10, 2014, 04:39:55 AM »
So i had to switch to setting a widgets alpha to 0 as opposed to deactivating the gameObject because upon reactivation the button did not detect interaction anymore and upon experimenting it was being blocked by elements that were higher in depth which would explain the aforementioned behaviour, but these elements were all in a different panel that was lower in depth then that of the element it was blocking. So run time in the scene editor i deactivated these objects that had uispriteimages with collider boxes and reactivated them and then all of a sudden they weren't blocking the aforementioned button anymore and i could interact with it. upon switching to setting the invisible via the alpha property this does not seem to happen anymore.

Are you not supposed to deactivate UIWidgets or other NGUI elements? and if so should i be using the alpha property or the widget.UpdateVisibility(bool,bool) function?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget SetAlpha = 0 vs SetActive(false)
« Reply #1 on: October 11, 2014, 04:05:03 AM »
When the widget's alpha is 0, it's no longer eligible for events.

Genhain

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: Widget SetAlpha = 0 vs SetActive(false)
« Reply #2 on: October 15, 2014, 05:27:49 AM »
Thankfully yes otherwise this would not be a feasible solution. my question was as i was saying at the end how should one make UIWidgets inactive? and making the alpha 0 seems to suffice, but upon speaking to my friend he said use NGUITools.SetActive().

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget SetAlpha = 0 vs SetActive(false)
« Reply #3 on: October 16, 2014, 06:14:03 AM »
NGUITools.SetActive just does gameObject.SetActive under the hood now. It deactivates the entire game object. This also disables all scripts you have on it -- if this is not what you want, just widget.enable = false.