Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Genhain on October 10, 2014, 04:39:55 AM

Title: Widget SetAlpha = 0 vs SetActive(false)
Post by: Genhain 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?
Title: Re: Widget SetAlpha = 0 vs SetActive(false)
Post by: ArenMook on October 11, 2014, 04:05:03 AM
When the widget's alpha is 0, it's no longer eligible for events.
Title: Re: Widget SetAlpha = 0 vs SetActive(false)
Post by: Genhain 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().
Title: Re: Widget SetAlpha = 0 vs SetActive(false)
Post by: ArenMook 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.